2019-04-02 03:23:03 +00:00
|
|
|
#[macro_use]
|
|
|
|
extern crate clap;
|
2019-04-09 03:35:14 +00:00
|
|
|
|
2019-04-19 20:57:14 +00:00
|
|
|
mod context;
|
2019-05-01 20:34:24 +00:00
|
|
|
mod module;
|
2019-04-04 00:14:26 +00:00
|
|
|
mod modules;
|
|
|
|
mod print;
|
2019-04-12 21:49:20 +00:00
|
|
|
mod segment;
|
2019-04-04 00:14:26 +00:00
|
|
|
|
2019-06-06 12:18:00 +00:00
|
|
|
use clap::{App, Arg, SubCommand};
|
2019-04-02 04:45:49 +00:00
|
|
|
|
2019-04-02 03:23:03 +00:00
|
|
|
fn main() {
|
2019-05-14 04:43:11 +00:00
|
|
|
pretty_env_logger::init();
|
|
|
|
|
2019-06-06 12:18:00 +00:00
|
|
|
let matches = App::new("Starship")
|
2019-04-13 04:33:50 +00:00
|
|
|
.about("The cross-shell prompt for astronauts. ✨🚀")
|
2019-04-02 03:30:53 +00:00
|
|
|
// pull the version number from Cargo.toml
|
|
|
|
.version(crate_version!())
|
|
|
|
// pull the authors from Cargo.toml
|
|
|
|
.author(crate_authors!())
|
2019-04-04 00:14:26 +00:00
|
|
|
.after_help("https://github.com/matchai/starship")
|
2019-06-06 12:18:00 +00:00
|
|
|
.subcommand(
|
|
|
|
SubCommand::with_name("prompt")
|
|
|
|
.about("Prints the full starship prompt")
|
|
|
|
.arg(
|
|
|
|
Arg::with_name("status_code")
|
|
|
|
.short("s")
|
|
|
|
.long("status")
|
|
|
|
.value_name("STATUS_CODE")
|
|
|
|
.help("The status code of the previously run command")
|
|
|
|
.takes_value(true),
|
|
|
|
)
|
|
|
|
.arg(
|
|
|
|
Arg::with_name("path")
|
|
|
|
.short("p")
|
|
|
|
.long("path")
|
|
|
|
.value_name("PATH")
|
|
|
|
.help("The path that the prompt should render for ($PWD by default)")
|
|
|
|
.takes_value(true),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
.subcommand(
|
|
|
|
SubCommand::with_name("module")
|
|
|
|
.about("Prints a specific prompt module")
|
|
|
|
.arg(
|
|
|
|
Arg::with_name("name")
|
|
|
|
.help("The name of the module to be printed")
|
|
|
|
.required(true),
|
|
|
|
)
|
|
|
|
.arg(
|
|
|
|
Arg::with_name("status_code")
|
|
|
|
.short("s")
|
|
|
|
.long("status")
|
|
|
|
.value_name("STATUS_CODE")
|
|
|
|
.help("The status code of the previously run command")
|
|
|
|
.takes_value(true),
|
|
|
|
)
|
|
|
|
.arg(
|
|
|
|
Arg::with_name("path")
|
|
|
|
.short("p")
|
|
|
|
.long("path")
|
|
|
|
.value_name("PATH")
|
|
|
|
.help("The path the prompt should render for ($PWD by default)")
|
|
|
|
.takes_value(true),
|
|
|
|
),
|
2019-04-04 02:57:50 +00:00
|
|
|
)
|
2019-04-02 03:30:53 +00:00
|
|
|
.get_matches();
|
2019-04-02 04:45:49 +00:00
|
|
|
|
2019-06-06 12:18:00 +00:00
|
|
|
match matches.subcommand() {
|
|
|
|
("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.");
|
|
|
|
print::module(module_name, sub_m.clone());
|
|
|
|
}
|
|
|
|
_ => {}
|
|
|
|
}
|
2019-04-02 03:23:03 +00:00
|
|
|
}
|