Skip to content

Commit 3ecb7ca

Browse files
committed
fix(cli): fix input handling error that made it mandatory during validation without need
1 parent bb2ae6c commit 3ecb7ca

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/main.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ struct Cli {
5555
/// Processed configuration from CLI arguments
5656
struct 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
115115
fn 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
});

0 commit comments

Comments
 (0)