File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ struct Cli {
5555/// Processed configuration from CLI arguments
5656struct Config {
5757 template : String ,
58- input : String ,
58+ input : Option < String > ,
5959 validate : bool ,
6060 quiet : bool ,
6161 debug : bool ,
@@ -114,7 +114,13 @@ fn get_input(cli: &Cli) -> Result<String, String> {
114114/// Build configuration from CLI arguments
115115fn build_config ( cli : Cli ) -> Result < Config , String > {
116116 let template = get_template ( & cli) ?;
117- let input = get_input ( & cli) ?;
117+
118+ // Skip input collection if we're only validating the template
119+ let input = if cli. validate {
120+ None
121+ } else {
122+ Some ( get_input ( & cli) ?)
123+ } ;
118124
119125 Ok ( Config {
120126 template,
@@ -247,8 +253,13 @@ fn main() {
247253 return ;
248254 }
249255
256+ // For non-validation, input is required
257+ let input = config
258+ . input
259+ . expect ( "Input should be available for non-validation operations" ) ;
260+
250261 // Process input with template
251- let result = template. format ( & config . input ) . unwrap_or_else ( |e| {
262+ let result = template. format ( & input) . unwrap_or_else ( |e| {
252263 eprintln ! ( "Error formatting input: {e}" ) ;
253264 std:: process:: exit ( 1 ) ;
254265 } ) ;
You can’t perform that action at this time.
0 commit comments