Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ path = "src/main.rs"
anyhow = "1"
clap = { version = "4", features = ["derive", "env"] }
clap_complete = "4"
clap_complete_nushell = "4"
flate2 = "1"
sha2 = "0.10"
tar = "0.4"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ On Linux and macOS, install the CLI with `curl -fsSL https://proofline.sh/cli |

A coding agent can continue setup from its shell without an MCP restart. `proofline setup guide` prints the instructions and needs no sign-in. `proofline setup status` prints the current setup step, readiness and blockers, and `proofline setup candidates [--query NAME]` lists the repositories and deployments an answer may name. Both print the hosted MCP tool result as JSON and need `setup:write`, like `proofline config get`. The agent saves answers with the [configuration commands](#configuration).

`proofline completions SHELL` prints a completion script for `zsh`, `bash`, `fish`, `powershell`, or `elvish` without signing in or making a network call. For example, add `source <(proofline completions zsh)` to `~/.zshrc`.
`proofline completions SHELL` prints a completion script for `zsh`, `bash`, `fish`, `powershell`, `elvish`, or `nushell` without signing in or making a network call. For example, add `source <(proofline completions zsh)` to `~/.zshrc`.

### Windows installation

Expand Down
46 changes: 41 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,14 @@ enum Command {
///
/// For example, add `source <(proofline completions zsh)` to `~/.zshrc`,
/// `proofline completions bash > ~/.local/share/bash-completion/completions/proofline`,
/// `proofline completions fish > ~/.config/fish/completions/proofline.fish`, or
/// `proofline completions fish > ~/.config/fish/completions/proofline.fish`,
/// `proofline completions powershell | Out-String | Invoke-Expression` to a
/// PowerShell profile.
/// PowerShell profile, or `proofline completions nushell | save -f
/// ~/.cache/proofline/completions.nu` and `source` that file from Nushell's
/// `config.nu`.
Completions {
/// The shell to complete for.
shell: clap_complete::Shell,
shell: CliShell,
},
/// Install the newest official release over this installer-managed binary.
Update,
Expand Down Expand Up @@ -183,6 +185,35 @@ enum Command {
Hook(hooks::HookArgs),
}

/// A shell that `completions` can print a script for: one of
/// [`clap_complete::Shell`]'s built-in generators, or Nushell, which `clap`
/// does not ship a generator for.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
enum CliShell {
Builtin(clap_complete::Shell),
Nushell,
}

impl clap::ValueEnum for CliShell {
fn value_variants<'a>() -> &'a [Self] {
&[
Self::Builtin(clap_complete::Shell::Bash),
Self::Builtin(clap_complete::Shell::Elvish),
Self::Builtin(clap_complete::Shell::Fish),
Self::Builtin(clap_complete::Shell::PowerShell),
Self::Builtin(clap_complete::Shell::Zsh),
Self::Nushell,
]
}

fn to_possible_value(&self) -> Option<clap::builder::PossibleValue> {
match self {
Self::Builtin(shell) => shell.to_possible_value(),
Self::Nushell => Some(clap::builder::PossibleValue::new("nushell")),
}
}
}

#[derive(Debug, Subcommand)]
enum CiCommand {
/// Wait for the pull-request review of the commit under test and report it.
Expand Down Expand Up @@ -667,7 +698,7 @@ async fn connect(

/// Writes the completion script for `shell`. It needs no origin, token or
/// network, so it works before `proofline login`.
fn completions(shell: clap_complete::Shell, out: &mut dyn std::io::Write) -> anyhow::Result<()> {
fn completions(shell: CliShell, out: &mut dyn std::io::Write) -> anyhow::Result<()> {
const NAME: &str = "proofline";
let full = <Cli as clap::CommandFactory>::command();
// The static generators offer hidden subcommands too, so leave them out.
Expand All @@ -680,7 +711,12 @@ fn completions(shell: clap_complete::Shell, out: &mut dyn std::io::Write) -> any
.filter(|subcommand| !subcommand.is_hide_set())
.cloned()
.fold(command, clap::Command::subcommand);
clap_complete::generate(shell, &mut command, NAME, out);
match shell {
CliShell::Builtin(shell) => clap_complete::generate(shell, &mut command, NAME, out),
CliShell::Nushell => {
clap_complete::generate(clap_complete_nushell::Nushell, &mut command, NAME, out);
}
}
out.flush()?;
Ok(())
}
Expand Down
1 change: 1 addition & 0 deletions tests/completions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ fn every_shell_gets_a_script_naming_the_visible_commands() {
("bash", "complete -F _proofline"),
("fish", "complete -c proofline"),
("powershell", "Register-ArgumentCompleter"),
("nushell", "module completions {"),
] {
let output = completions(shell);
assert!(output.status.success(), "{shell}: {output:?}");
Expand Down