diff options
author | Matan Kushner <hello@matchai.me> | 2019-07-03 08:03:02 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-03 08:03:02 -0400 |
commit | d7754f38e7959bd2d16406913c6776ad7c6ac8d6 (patch) | |
tree | ca7616a52ac880bf48a3a869aa2a85c6425fae09 /src/main.rs | |
parent | 5ad3e0059a50a4c5fc68a602916c5787ae152d21 (diff) |
feat: Implement simplified prompt setup process (#90)
• Add starship init which prints the shell function used to execute starship
• Document the new setup process using starship init
• Remove benchmarks for now (WIP replacement benchmarks in "benchmarking" branch )
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs index 371109e50..a7ac01a64 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,13 +3,14 @@ extern crate clap; mod config; mod context; +mod init; mod module; mod modules; mod print; mod segment; mod utils; -use clap::{App, Arg, SubCommand}; +use clap::{App, AppSettings, Arg, SubCommand}; fn main() { pretty_env_logger::init(); @@ -28,13 +29,26 @@ fn main() { .help("The path that the prompt should render for") .takes_value(true); - let matches = App::new("Starship") - .about("The cross-shell prompt for astronauts. ✨🚀") + let shell_arg = Arg::with_name("shell") + .value_name("SHELL") + .help( + "The name of the currently running shell\nCurrently supported options: bash, zsh, fish", + ) + .required(true); + + let matches = App::new("starship") + .about("The cross-shell prompt for astronauts. ☄🌌️") // pull the version number from Cargo.toml .version(crate_version!()) // pull the authors from Cargo.toml .author(crate_authors!()) - .after_help("https://github.com/matchai/starship") + .after_help("https://github.com/starship/starship") + .setting(AppSettings::SubcommandRequiredElseHelp) + .subcommand( + SubCommand::with_name("init") + .about("Prints the shell function used to execute starship") + .arg(&shell_arg), + ) .subcommand( SubCommand::with_name("prompt") .about("Prints the full starship prompt") @@ -55,6 +69,10 @@ fn main() { .get_matches(); match matches.subcommand() { + ("init", Some(sub_m)) => { + let shell_name = sub_m.value_of("shell").expect("Shell name missing."); + init::init(shell_name) + } ("prompt", Some(sub_m)) => print::prompt(sub_m.clone()), ("module", Some(sub_m)) => { let module_name = sub_m.value_of("name").expect("Module name missing."); |