Skip to content

Commit 5fa5cbc

Browse files
fix: align cwd flag names
1 parent 7954d02 commit 5fa5cbc

3 files changed

Lines changed: 41 additions & 3 deletions

File tree

src/cortex-cli/src/acp_cmd.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use std::path::PathBuf;
1414
#[command(about = "Start an ACP (Agent Client Protocol) server for IDE integration")]
1515
pub struct AcpCli {
1616
/// Working directory for the session.
17-
#[arg(long = "cwd", short = 'C', value_name = "DIR")]
17+
#[arg(long = "cwd", alias = "cd", short = 'C', value_name = "DIR")]
1818
pub cwd: Option<PathBuf>,
1919

2020
/// Port to listen on (default: random available port).
@@ -161,6 +161,14 @@ mod tests {
161161
assert_eq!(cli.cwd, Some(PathBuf::from("/home/user/project")));
162162
}
163163

164+
#[test]
165+
fn test_acp_cli_cwd_cd_alias() {
166+
let cli = AcpCli::try_parse_from(["acp", "--cd", "/home/user/project"])
167+
.expect("should parse --cd alias");
168+
169+
assert_eq!(cli.cwd, Some(PathBuf::from("/home/user/project")));
170+
}
171+
164172
#[test]
165173
fn test_acp_cli_cwd_short_option() {
166174
let cli = AcpCli::try_parse_from(["acp", "-C", "/tmp/test"]).expect("should parse");

src/cortex-cli/src/cli/args.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ pub struct InteractiveArgs {
189189

190190
/// Tell the agent to use the specified directory as its working root
191191
#[arg(
192-
long = "cd",
192+
long = "cwd",
193+
alias = "cd",
193194
short = 'C',
194195
value_name = "DIR",
195196
help_heading = "Workspace"
@@ -1106,11 +1107,29 @@ mod tests {
11061107

11071108
#[test]
11081109
fn test_cli_cwd_long() {
1110+
let cli =
1111+
Cli::try_parse_from(["cortex", "--cwd", "/tmp/project"]).expect("should parse --cwd");
1112+
assert_eq!(cli.interactive.cwd, Some(PathBuf::from("/tmp/project")));
1113+
}
1114+
1115+
#[test]
1116+
fn test_cli_cwd_cd_alias() {
11091117
let cli =
11101118
Cli::try_parse_from(["cortex", "--cd", "/tmp/project"]).expect("should parse --cd");
11111119
assert_eq!(cli.interactive.cwd, Some(PathBuf::from("/tmp/project")));
11121120
}
11131121

1122+
#[test]
1123+
fn test_cli_cwd_help_uses_canonical_name() {
1124+
use clap::CommandFactory;
1125+
1126+
let mut cmd = Cli::command();
1127+
let help = cmd.render_long_help().to_string();
1128+
1129+
assert!(help.contains("--cwd <DIR>"));
1130+
assert!(!help.contains("--cd <DIR>"));
1131+
}
1132+
11141133
#[test]
11151134
fn test_cli_add_dir() {
11161135
let cli = Cli::try_parse_from(["cortex", "--add-dir", "/extra/dir"])

src/cortex-cli/src/shell_cmd.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub struct ShellCli {
2020
pub model: Option<String>,
2121

2222
/// Working directory override
23-
#[arg(long = "cwd", short = 'C')]
23+
#[arg(long = "cwd", alias = "cd", short = 'C')]
2424
pub cwd: Option<PathBuf>,
2525

2626
/// Configuration profile from config.toml
@@ -188,6 +188,17 @@ mod tests {
188188
);
189189
}
190190

191+
#[test]
192+
fn test_shell_cli_cwd_cd_alias() {
193+
let cli = ShellCli::parse_from(["shell", "--cd", "/home/user/workspace"]);
194+
195+
assert_eq!(
196+
cli.cwd,
197+
Some(PathBuf::from("/home/user/workspace")),
198+
"CWD should be set via --cd alias"
199+
);
200+
}
201+
191202
#[test]
192203
fn test_shell_cli_cwd_relative_path() {
193204
let cli = ShellCli::parse_from(["shell", "--cwd", "relative/path"]);

0 commit comments

Comments
 (0)