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
10 changes: 10 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 @@ -340,6 +340,7 @@ camino = "1.1.1"
cfg-if = "1.0.0"
chrono = { version = "0.4.39", features = ["clock", "serde"] }
clap = { version = "4.4", features = ["derive", "wrap_help"] }
clap_complete = "4.4"
codespan-reporting = "0.11.1"
collectable = "0.0.2"
colored = "2.0.0"
Expand Down
1 change: 1 addition & 0 deletions crates/sui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ bin-version.workspace = true
bip32.workspace = true
camino.workspace = true
clap.workspace = true
clap_complete.workspace = true
codespan-reporting.workspace = true
datatest-stable.workspace = true
futures.workspace = true
Expand Down
14 changes: 14 additions & 0 deletions crates/sui/src/sui_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,14 @@ pub enum SuiCommand {
#[command(flatten)]
replay_config: SR2::ReplayConfigStable,
},

/// Generate shell completion scripts for CLI
#[clap(name = "completion")]
Completion {
/// If provided, outputs the completion file for given shell
#[arg(long = "generate", value_enum)]
generator: clap_complete::Shell,
},
}

impl SuiCommand {
Expand Down Expand Up @@ -839,6 +847,12 @@ impl SuiCommand {

Ok(())
}
SuiCommand::Completion { generator } => {
let mut app: Command = SuiCommand::command();
let name = app.get_name().to_string();
clap_complete::generate(generator, &mut app, name, &mut std::io::stdout());
Ok(())
}
}
}
}
Expand Down