11mod app;
22mod executor;
3+ mod run;
34mod util;
45
5- use std:: { path:: PathBuf , process} ;
6+ use std:: path:: PathBuf ;
7+ use std:: process;
68
79use anyhow:: Result ;
8- use clap:: { Parser , Subcommand , ValueEnum } ;
10+ use clap:: { Parser , Subcommand } ;
911use yansi:: Paint ;
1012
11- use app:: App ;
13+ use crate :: app:: App ;
1214
1315/// A command line tool to run various Rosetta applications
1416#[ derive( Parser , Debug ) ]
@@ -27,15 +29,6 @@ struct Args {
2729 verbose : bool ,
2830}
2931
30- #[ derive( ValueEnum , Clone , Copy , Debug , strum:: Display ) ]
31- #[ strum( serialize_all = "lowercase" ) ] // "kebab-case"
32- enum ContainerEngine {
33- Docker ,
34- Singularity ,
35- Apptainer ,
36- None ,
37- }
38-
3932#[ derive( Subcommand , Debug ) ]
4033enum Commands {
4134 /// Clean an app installation
@@ -67,8 +60,65 @@ enum Commands {
6760 working_dir : Option < PathBuf > ,
6861
6962 #[ arg( short = 'e' , long, default_value = "docker" ) ]
70- container_engine : ContainerEngine ,
63+ container_engine : run:: ContainerEngine ,
64+ } ,
65+
66+ Config {
67+ #[ command( subcommand) ]
68+ config_command : ConfigCmd ,
69+ } ,
70+ }
71+
72+ #[ derive( Subcommand , Debug ) ]
73+ enum ConfigCmd {
74+ /// Show the effective configuration
75+ Show ( ConfigShowArgs ) ,
76+
77+ /// Get a single configuration value
78+ Get {
79+ /// Dotted key path, e.g. `cache.root`
80+ key : String ,
81+
82+ /// Output as JSON (useful for scripting)
83+ #[ arg( long) ]
84+ json : bool ,
85+ } ,
86+
87+ /// Set a configuration value
88+ Set {
89+ /// Dotted key path, e.g. `cache.root`
90+ key : String ,
91+
92+ /// Value to set (stringly-typed; you parse/validate per key)
93+ value : String ,
7194 } ,
95+
96+ /// Remove a configuration override (fall back to defaults)
97+ Unset {
98+ /// Dotted key path, e.g. `cache.root`
99+ key : String ,
100+ } ,
101+
102+ /// Open the config file in $EDITOR
103+ Edit ,
104+
105+ /// Print the config file path
106+ Path ,
107+ }
108+
109+ #[ derive( clap:: Args , Debug ) ]
110+ struct ConfigShowArgs {
111+ /// Output as JSON (useful for scripting)
112+ #[ arg( long) ]
113+ json : bool ,
114+
115+ /// Output as TOML (optional; pick what you support)
116+ #[ arg( long, conflicts_with = "json" ) ]
117+ toml : bool ,
118+
119+ /// Include where each value came from (defaults/env/file)
120+ #[ arg( long) ]
121+ origin : bool ,
72122}
73123
74124fn main ( ) -> Result < ( ) > {
@@ -100,8 +150,12 @@ fn main() -> Result<()> {
100150 . canonicalize ( )
101151 . unwrap ( ) ;
102152
103- executor :: run ( app, app_args. clone ( ) , container_engine, working_dir)
153+ run :: run ( app, app_args. clone ( ) , container_engine, working_dir)
104154 }
155+ Some ( Commands :: Config { config_command : _ } ) => {
156+ todo ! ( ) ;
157+ }
158+
105159 None => {
106160 eprintln ! ( "Error: No command specified" ) ;
107161 eprintln ! ( "Use --help to see available commands" ) ;
0 commit comments