Skip to content

armgit / herdr

Public Imported from GitHub
0

the runtime your coding agents live on

fix: accept session names after option terminator (#3222)

akbash6a93b756e939
diff --git a/src/cli.rs b/src/cli.rs
index ea643f6ab..d4ae2f844 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -966,8 +966,11 @@ fn parse_session_json_only(args: &[String], usage: &str) -> Result<bool, i32> {
fn parse_session_name_and_json(args: &[String], usage: &str) -> Result<(String, bool), i32> {
let mut name = None;
let mut json = false;
+ let mut options_ended = false;
for arg in args {
- if arg == "--json" {
+ if !options_ended && arg == "--" {
+ options_ended = true;
+ } else if !options_ended && arg == "--json" {
json = true;
} else if name.is_none() {
name = Some(arg.clone());
@@ -1087,6 +1090,16 @@ mod tests {
);
}
+ #[test]
+ fn session_name_parser_accepts_option_terminator() {
+ for name in ["-h", "--json"] {
+ assert_eq!(
+ super::parse_session_name_and_json(&["--".to_string(), name.to_string()], "usage",),
+ Ok((name.to_string(), false))
+ );
+ }
+ }
+
#[test]
fn parse_env_assignment_accepts_empty_values() {
assert_eq!(