diff --git a/gossip-bin/src/commands.rs b/gossip-bin/src/commands.rs index 0ba6edeb..9aff3777 100644 --- a/gossip-bin/src/commands.rs +++ b/gossip-bin/src/commands.rs @@ -25,7 +25,7 @@ impl Command { } } -const COMMANDS: [Command; 38] = [ +const COMMANDS: [Command; 39] = [ Command { cmd: "oneshot", usage_params: "{depends}", @@ -196,6 +196,11 @@ const COMMANDS: [Command; 38] = [ usage_params: "", desc: "Reprocess relay lists (including kind 3 contents)", }, + Command { + cmd: "theme", + usage_params: "", + desc: "Start gossip with the selected theme", + }, Command { cmd: "ungiftwrap", usage_params: "", @@ -274,6 +279,10 @@ pub fn handle_command(mut args: env::Args, runtime: &Runtime) -> Result rename_person_list(command, args)?, "reprocess_recent" => reprocess_recent(command, runtime)?, "reprocess_relay_lists" => reprocess_relay_lists()?, + "theme" => { + set_theme(command, args)?; + return Ok(false); + } "ungiftwrap" => ungiftwrap(command, args)?, "verify" => verify(command, args)?, "verify_json" => verify_json(command, args)?, @@ -986,6 +995,27 @@ pub fn reprocess_relay_lists() -> Result<(), Error> { Ok(()) } +pub fn set_theme(cmd: Command, mut args: env::Args) -> Result<(), Error> { + let theme = match args.next() { + Some(s) => s, + None => return cmd.usage("Missing theme selection".to_string()), + }; + + match theme.as_str() { + "dark" => { + GLOBALS.storage.write_setting_dark_mode(&true, None)?; + println!("Setting 'dark' theme"); + } + "light" => { + GLOBALS.storage.write_setting_dark_mode(&false, None)?; + println!("Setting 'light' theme"); + } + _ => return cmd.usage("Invalid theme selection".to_string()), + }; + + Ok(()) +} + pub fn verify(cmd: Command, mut args: env::Args) -> Result<(), Error> { let idstr = match args.next() { Some(id) => id,