Fix: CLI generate command works with single invocation
The remove_env_flags function was incorrectly returning index 0 when no --env flag was present, causing it to mistakenly skip the first argument (program name) and shift all arguments incorrectly. This required users to specify 'generate' twice to make the CLI work. Fix by checking if --env was actually found (env_idx > 0) before removing any arguments from the list.
This commit is contained in:
@@ -263,6 +263,9 @@ fn parse_env_flag(args: &[String]) -> (Env, usize) {
|
||||
/// command without affecting positional argument parsing.
|
||||
fn remove_env_flags(args: &[String]) -> Vec<String> {
|
||||
let (_, env_idx) = parse_env_flag(args);
|
||||
if env_idx == 0 {
|
||||
return args.to_vec();
|
||||
}
|
||||
let mut result = Vec::with_capacity(args.len());
|
||||
|
||||
for (i, arg) in args.iter().enumerate() {
|
||||
|
||||
Reference in New Issue
Block a user