1
0
mirror of https://github.com/Llewellynvdm/starship.git synced 2025-04-07 09:41:50 +00:00

feat(explain): allow specifying prompt arguments in explain and timings subcommands (#3042)

This commit is contained in:
David Knaack 2021-10-03 16:08:18 +02:00 committed by GitHub
parent 68694029c4
commit 8f82457c2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -81,126 +81,143 @@ fn main() {
.help("Print the main initialization script (as opposed to the init stub)"); .help("Print the main initialization script (as opposed to the init stub)");
let long_version = crate::shadow::clap_version(); let long_version = crate::shadow::clap_version();
let mut app = App::new("starship") let mut app =
.about("The cross-shell prompt for astronauts. ☄🌌️") App::new("starship")
// pull the version number from Cargo.toml .about("The cross-shell prompt for astronauts. ☄🌌️")
.version(shadow::PKG_VERSION) // pull the version number from Cargo.toml
.long_version(long_version.as_str()) .version(shadow::PKG_VERSION)
// pull the authors from Cargo.toml .long_version(long_version.as_str())
.author(crate_authors!()) // pull the authors from Cargo.toml
.after_help("https://github.com/starship/starship") .author(crate_authors!())
.setting(AppSettings::SubcommandRequiredElseHelp) .after_help("https://github.com/starship/starship")
.subcommand( .setting(AppSettings::SubcommandRequiredElseHelp)
SubCommand::with_name("init") .subcommand(
.about("Prints the shell function used to execute starship") SubCommand::with_name("init")
.arg(&shell_arg) .about("Prints the shell function used to execute starship")
.arg(&init_scripts_arg), .arg(&shell_arg)
) .arg(&init_scripts_arg),
.subcommand( )
SubCommand::with_name("prompt") .subcommand(
.about("Prints the full starship prompt") SubCommand::with_name("prompt")
.arg( .about("Prints the full starship prompt")
Arg::with_name("right") .arg(
.long("right") Arg::with_name("right")
.help("Print the right prompt (instead of the standard left prompt)"), .long("right")
) .help("Print the right prompt (instead of the standard left prompt)"),
.arg(&status_code_arg) )
.arg(&pipestatus_arg) .arg(&status_code_arg)
.arg(&path_arg) .arg(&pipestatus_arg)
.arg(&logical_path_arg) .arg(&path_arg)
.arg(&cmd_duration_arg) .arg(&logical_path_arg)
.arg(&keymap_arg) .arg(&cmd_duration_arg)
.arg(&jobs_arg), .arg(&keymap_arg)
) .arg(&jobs_arg),
.subcommand( )
SubCommand::with_name("module") .subcommand(
.about("Prints a specific prompt module") SubCommand::with_name("module")
.arg( .about("Prints a specific prompt module")
Arg::with_name("name") .arg(
.help("The name of the module to be printed") Arg::with_name("name")
.required(true) .help("The name of the module to be printed")
.required_unless("list"), .required(true)
) .required_unless("list"),
.arg( )
Arg::with_name("list") .arg(
.short("l") Arg::with_name("list")
.long("list") .short("l")
.help("List out all supported modules"), .long("list")
) .help("List out all supported modules"),
.arg(&status_code_arg) )
.arg(&pipestatus_arg) .arg(&status_code_arg)
.arg(&path_arg) .arg(&pipestatus_arg)
.arg(&logical_path_arg) .arg(&path_arg)
.arg(&cmd_duration_arg) .arg(&logical_path_arg)
.arg(&keymap_arg) .arg(&cmd_duration_arg)
.arg(&jobs_arg), .arg(&keymap_arg)
) .arg(&jobs_arg),
.subcommand( )
SubCommand::with_name("config") .subcommand(
.alias("configure") SubCommand::with_name("config")
.about("Edit the starship configuration") .alias("configure")
.arg( .about("Edit the starship configuration")
Arg::with_name("name") .arg(
.help("Configuration key to edit") Arg::with_name("name")
.required(false) .help("Configuration key to edit")
.requires("value"), .required(false)
) .requires("value"),
.arg(Arg::with_name("value").help("Value to place into that key")), )
) .arg(Arg::with_name("value").help("Value to place into that key")),
.subcommand( )
SubCommand::with_name("print-config") .subcommand(
.about("Prints the computed starship configuration") SubCommand::with_name("print-config")
.arg( .about("Prints the computed starship configuration")
Arg::with_name("default") .arg(
.short("d") Arg::with_name("default")
.long("default") .short("d")
.help("Print the default instead of the computed config") .long("default")
.takes_value(false), .help("Print the default instead of the computed config")
), .takes_value(false),
) ),
.subcommand( )
SubCommand::with_name("toggle") .subcommand(
.about("Toggle a given starship module") SubCommand::with_name("toggle")
.arg( .about("Toggle a given starship module")
Arg::with_name("name") .arg(
.help("The name of the module to be toggled") Arg::with_name("name")
.required(true), .help("The name of the module to be toggled")
) .required(true),
.arg( )
Arg::with_name("key") .arg(
.help("The key of the config to be toggled") Arg::with_name("key")
.required(false) .help("The key of the config to be toggled")
.required_unless("name"), .required(false)
), .required_unless("name"),
) ),
.subcommand( )
SubCommand::with_name("bug-report").about( .subcommand(SubCommand::with_name("bug-report").about(
"Create a pre-populated GitHub issue with information about your configuration", "Create a pre-populated GitHub issue with information about your configuration",
), ))
) .subcommand(
.subcommand( SubCommand::with_name("time")
SubCommand::with_name("time") .about("Prints time in milliseconds")
.about("Prints time in milliseconds") .settings(&[AppSettings::Hidden]),
.settings(&[AppSettings::Hidden]), )
) .subcommand(
.subcommand( SubCommand::with_name("explain")
SubCommand::with_name("explain").about("Explains the currently showing modules"), .about("Explains the currently showing modules")
) .arg(&status_code_arg)
.subcommand(SubCommand::with_name("timings").about("Prints timings of all active modules")) .arg(&pipestatus_arg)
.subcommand( .arg(&path_arg)
SubCommand::with_name("completions") .arg(&logical_path_arg)
.about("Generate starship shell completions for your shell to stdout") .arg(&cmd_duration_arg)
.arg( .arg(&keymap_arg)
Arg::with_name("shell") .arg(&jobs_arg),
.takes_value(true) )
.possible_values(&Shell::variants()) .subcommand(
.help("the shell to generate completions for") SubCommand::with_name("timings")
.value_name("SHELL") .about("Prints timings of all active modules")
.required(true) .arg(&status_code_arg)
.env("STARSHIP_SHELL"), .arg(&pipestatus_arg)
), .arg(&path_arg)
) .arg(&logical_path_arg)
.subcommand(SubCommand::with_name("session").about("Generate random session key")); .arg(&cmd_duration_arg)
.arg(&keymap_arg)
.arg(&jobs_arg),
)
.subcommand(
SubCommand::with_name("completions")
.about("Generate starship shell completions for your shell to stdout")
.arg(
Arg::with_name("shell")
.takes_value(true)
.possible_values(&Shell::variants())
.help("the shell to generate completions for")
.value_name("SHELL")
.required(true)
.env("STARSHIP_SHELL"),
),
)
.subcommand(SubCommand::with_name("session").about("Generate random session key"));
let matches = app.clone().get_matches(); let matches = app.clone().get_matches();