diff options
author | Dom Slee <domslee1@gmail.com> | 2023-04-14 10:29:21 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-13 19:29:21 -0500 |
commit | ce7f984932a97b4ad3cd6e6ece8e1c3b6022ba99 (patch) | |
tree | 1c302efdd56718c7c86594dd0cc36a68f4d62df6 /src/main.rs | |
parent | b44f22e3753d171c0fd05391a40a1ad2acd8a5dd (diff) |
fix(config): Make print-config not panic without a config (#5001)
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs index dc01666b4..cc30950a4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,7 +10,7 @@ use clap::{CommandFactory, Parser, Subcommand}; use clap_complete::{generate, Shell as CompletionShell}; use rand::distributions::Alphanumeric; use rand::Rng; -use starship::context::{Properties, Target}; +use starship::context::{Context, Properties, Target}; use starship::module::ALL_MODULES; use starship::*; @@ -208,17 +208,22 @@ fn main() { } Commands::Preset { name, list, output } => print::preset_command(name, output, list), Commands::Config { name, value } => { + let context = Context::default(); if let Some(name) = name { if let Some(value) = value { - configure::update_configuration(&name, &value) + configure::update_configuration(&context, &name, &value) } - } else if let Err(reason) = configure::edit_configuration(None) { + } else if let Err(reason) = configure::edit_configuration(&context, None) { eprintln!("Could not edit configuration: {reason}"); std::process::exit(1); } } - Commands::PrintConfig { default, name } => configure::print_configuration(default, &name), - Commands::Toggle { name, value } => configure::toggle_configuration(&name, &value), + Commands::PrintConfig { default, name } => { + configure::print_configuration(&Context::default(), default, &name); + } + Commands::Toggle { name, value } => { + configure::toggle_configuration(&Context::default(), &name, &value) + } Commands::BugReport => bug_report::create(), Commands::Time => { match SystemTime::now() |