mirror of
https://github.com/Llewellynvdm/starship.git
synced 2024-06-08 19:32:21 +00:00
8239fbd12b
- Create subcommands to be able to print modules independently
- `starship prompt` will print the full prompt
- `starship module <MODULE_NAME>` will print a specific module
e.g. `starship module python`
- Added `--path` flag to print the prompt or modules without being in a specific directory
- Added `--status` flag to provide the status of the last command, instead of requiring it as an argument
- Refactored integration tests to be end-to-end tests, since there was no way in integration tests to set the environment variables for a specific command, which was required for the `username` module
- Moved e2e tests to `tests/testsuite` to allow for a single binary to be built
- Tests will build/run faster
- No more false positives for unused functions
- Added tests for `username`
- Removed codecov + tarpaulin 😢
78 lines
2.6 KiB
Rust
78 lines
2.6 KiB
Rust
#[macro_use]
|
|
extern crate clap;
|
|
|
|
mod context;
|
|
mod module;
|
|
mod modules;
|
|
mod print;
|
|
mod segment;
|
|
|
|
use clap::{App, Arg, SubCommand};
|
|
|
|
fn main() {
|
|
pretty_env_logger::init();
|
|
|
|
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")
|
|
.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),
|
|
),
|
|
)
|
|
.get_matches();
|
|
|
|
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());
|
|
}
|
|
_ => {}
|
|
}
|
|
}
|