summaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorKevin Song <chipbuster@users.noreply.github.com>2019-08-19 18:44:53 -0700
committerGitHub <noreply@github.com>2019-08-19 18:44:53 -0700
commit0e82c19f37e80e258ad7f0e6136a2bcf37c9648a (patch)
treeefa2adad7938bbeafa9bbfcfedf37f6f37114395 /src/main.rs
parent2e39c6d0fade30a996c068dceb3d5133d1baf3a6 (diff)
feat: Implement a two-phase init which allows us to write normal init scripts (#168)
Implement a two-phase init procedure in starship. The first phase causes the shell to source a subshell, while the second phase (in the subshell) prints the main init script. This allows us to have nice init scripts with good styling, comments, and no pile of semicolons. Even better, it works as a drop-in replacement, so we don't need to update the docs.
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index 523b2d9bc..7143a59bf 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -58,6 +58,10 @@ fn main() {
.help("The number of currently running jobs")
.takes_value(true);
+ let init_scripts_arg = Arg::with_name("print_full_init")
+ .long("print-full-init")
+ .help("Print the main initialization script (as opposed to the init stub)");
+
let matches = App::new("starship")
.about("The cross-shell prompt for astronauts. ☄🌌️")
// pull the version number from Cargo.toml
@@ -69,7 +73,8 @@ fn main() {
.subcommand(
SubCommand::with_name("init")
.about("Prints the shell function used to execute starship")
- .arg(&shell_arg),
+ .arg(&shell_arg)
+ .arg(&init_scripts_arg),
)
.subcommand(
SubCommand::with_name("prompt")
@@ -99,7 +104,11 @@ fn main() {
match matches.subcommand() {
("init", Some(sub_m)) => {
let shell_name = sub_m.value_of("shell").expect("Shell name missing.");
- init::init(shell_name)
+ if sub_m.is_present("print_full_init") {
+ init::init_main(shell_name);
+ } else {
+ init::init_stub(shell_name);
+ }
}
("prompt", Some(sub_m)) => print::prompt(sub_m.clone()),
("module", Some(sub_m)) => {