1- use crate :: cli:: args:: { CacheCommands , Cli , Commands , RepoCommands , ThemeCommands } ;
1+ use crate :: cli:: args:: { CacheCommands , Cli , Commands , RepoCommands } ;
22use crate :: cli:: commands:: {
33 run_export, run_game_session, run_history, run_repo_clear, run_repo_list, run_repo_play,
44 run_stats,
@@ -20,7 +20,6 @@ pub async fn run_cli(cli: Cli) -> Result<()> {
2020 Some ( Commands :: Export { format, output } ) => run_export ( format. clone ( ) , output. clone ( ) ) ,
2121 Some ( Commands :: Cache { cache_command } ) => run_cache_command ( cache_command) ,
2222 Some ( Commands :: Repo { repo_command } ) => run_repo_command ( repo_command) ,
23- Some ( Commands :: Theme { theme_command } ) => run_theme_command ( theme_command) ,
2423 None => run_game_session ( cli) ,
2524 }
2625}
@@ -96,79 +95,3 @@ fn run_repo_command(repo_command: &RepoCommands) -> Result<()> {
9695 }
9796}
9897
99- fn run_theme_command ( theme_command : & ThemeCommands ) -> Result < ( ) > {
100- use crate :: config:: ConfigManager ;
101- use crate :: ui:: color_mode:: ColorMode ;
102- use crate :: ui:: theme:: Theme ;
103-
104- let mut config_manager = ConfigManager :: new ( )
105- . map_err ( |e| crate :: GitTypeError :: TerminalError ( e. to_string ( ) ) ) ?;
106-
107- match theme_command {
108- ThemeCommands :: List => {
109- println ! ( "Available themes:" ) ;
110- let themes = Theme :: all_themes ( ) ;
111- let current_theme_id = & config_manager. get_config ( ) . theme . current_theme . id ;
112-
113- for theme in themes {
114- let current_indicator = if current_theme_id == & theme. id {
115- " (current)"
116- } else {
117- ""
118- } ;
119- println ! ( " {}{}" , theme. id, current_indicator) ;
120- }
121- }
122- ThemeCommands :: Set { theme } => {
123- let theme_obj = Theme :: all_themes ( )
124- . into_iter ( )
125- . find ( |t| t. id == * theme)
126- . ok_or_else ( || crate :: GitTypeError :: TerminalError ( format ! ( "Unknown theme: {}" , theme) ) ) ?;
127-
128- config_manager. get_config_mut ( ) . theme . current_theme = theme_obj;
129- config_manager. save ( )
130- . map_err ( |e| crate :: GitTypeError :: TerminalError ( e. to_string ( ) ) ) ?;
131-
132- println ! ( "Theme set to: {}" , theme) ;
133- }
134- ThemeCommands :: Current => {
135- let current_theme = & config_manager. get_config ( ) . theme . current_theme . id ;
136- let current_mode = match config_manager. get_config ( ) . theme . current_color_mode {
137- ColorMode :: Dark => "dark" ,
138- ColorMode :: Light => "light" ,
139- } ;
140- println ! ( "Current theme: {} ({})" , current_theme, current_mode) ;
141- }
142- ThemeCommands :: Mode { mode } => {
143- let color_mode = match mode. to_lowercase ( ) . as_str ( ) {
144- "dark" => ColorMode :: Dark ,
145- "light" => ColorMode :: Light ,
146- _ => return Err ( crate :: GitTypeError :: TerminalError ( format ! ( "Invalid color mode: {}. Use 'dark' or 'light'" , mode) ) ) ,
147- } ;
148-
149- config_manager. get_config_mut ( ) . theme . current_color_mode = color_mode;
150- config_manager. save ( )
151- . map_err ( |e| crate :: GitTypeError :: TerminalError ( e. to_string ( ) ) ) ?;
152-
153- println ! ( "Color mode set to: {}" , mode) ;
154- }
155- ThemeCommands :: Toggle => {
156- let new_mode = match config_manager. get_config ( ) . theme . current_color_mode {
157- ColorMode :: Dark => ColorMode :: Light ,
158- ColorMode :: Light => ColorMode :: Dark ,
159- } ;
160-
161- config_manager. get_config_mut ( ) . theme . current_color_mode = new_mode. clone ( ) ;
162- config_manager. save ( )
163- . map_err ( |e| crate :: GitTypeError :: TerminalError ( e. to_string ( ) ) ) ?;
164-
165- let mode_str = match new_mode {
166- ColorMode :: Dark => "dark" ,
167- ColorMode :: Light => "light" ,
168- } ;
169- println ! ( "Color mode toggled to: {}" , mode_str) ;
170- }
171- }
172-
173- Ok ( ( ) )
174- }
0 commit comments