Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/cortex-cli/src/acp_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use std::path::PathBuf;
#[command(about = "Start an ACP (Agent Client Protocol) server for IDE integration")]
pub struct AcpCli {
/// Working directory for the session.
#[arg(long = "cwd", short = 'C', value_name = "DIR")]
#[arg(long = "cwd", alias = "cd", short = 'C', value_name = "DIR")]
pub cwd: Option<PathBuf>,

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

#[test]
fn test_acp_cli_cwd_cd_alias() {
let cli = AcpCli::try_parse_from(["acp", "--cd", "/home/user/project"])
.expect("should parse --cd alias");

assert_eq!(cli.cwd, Some(PathBuf::from("/home/user/project")));
}

#[test]
fn test_acp_cli_cwd_short_option() {
let cli = AcpCli::try_parse_from(["acp", "-C", "/tmp/test"]).expect("should parse");
Expand Down
5 changes: 2 additions & 3 deletions src/cortex-cli/src/agent_cmd/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
#[cfg(test)]
mod tests {
use crate::agent_cmd::cli::{CopyArgs, ExportArgs};
use crate::agent_cmd::loader::{
load_builtin_agents, parse_frontmatter, read_file_with_encoding,
};
use crate::agent_cmd::loader::{load_builtin_agents, parse_frontmatter};
use crate::agent_cmd::types::AgentMode;
use crate::utils::file::read_file_with_encoding;

#[test]
fn test_read_file_with_utf8() {
Expand Down
21 changes: 20 additions & 1 deletion src/cortex-cli/src/cli/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ pub struct InteractiveArgs {

/// Tell the agent to use the specified directory as its working root
#[arg(
long = "cd",
long = "cwd",
alias = "cd",
short = 'C',
value_name = "DIR",
help_heading = "Workspace"
Expand Down Expand Up @@ -1106,11 +1107,29 @@ mod tests {

#[test]
fn test_cli_cwd_long() {
let cli =
Cli::try_parse_from(["cortex", "--cwd", "/tmp/project"]).expect("should parse --cwd");
assert_eq!(cli.interactive.cwd, Some(PathBuf::from("/tmp/project")));
}

#[test]
fn test_cli_cwd_cd_alias() {
let cli =
Cli::try_parse_from(["cortex", "--cd", "/tmp/project"]).expect("should parse --cd");
assert_eq!(cli.interactive.cwd, Some(PathBuf::from("/tmp/project")));
}

#[test]
fn test_cli_cwd_help_uses_canonical_name() {
use clap::CommandFactory;

let mut cmd = Cli::command();
let help = cmd.render_long_help().to_string();

assert!(help.contains("--cwd <DIR>"));
assert!(!help.contains("--cd <DIR>"));
}

#[test]
fn test_cli_add_dir() {
let cli = Cli::try_parse_from(["cortex", "--add-dir", "/extra/dir"])
Expand Down
13 changes: 12 additions & 1 deletion src/cortex-cli/src/shell_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub struct ShellCli {
pub model: Option<String>,

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

/// Configuration profile from config.toml
Expand Down Expand Up @@ -188,6 +188,17 @@ mod tests {
);
}

#[test]
fn test_shell_cli_cwd_cd_alias() {
let cli = ShellCli::parse_from(["shell", "--cd", "/home/user/workspace"]);

assert_eq!(
cli.cwd,
Some(PathBuf::from("/home/user/workspace")),
"CWD should be set via --cd alias"
);
}

#[test]
fn test_shell_cli_cwd_relative_path() {
let cli = ShellCli::parse_from(["shell", "--cwd", "relative/path"]);
Expand Down
3 changes: 3 additions & 0 deletions src/cortex-cli/src/utils/notification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ pub enum NotificationUrgency {
/// # Returns
/// `Ok(())` on success (or silent failure if notifications unavailable).
pub fn send_notification(title: &str, body: &str, urgency: NotificationUrgency) -> Result<()> {
#[cfg(not(target_os = "linux"))]
let _ = urgency;

#[cfg(target_os = "macos")]
{
send_notification_macos(title, body)?;
Expand Down
3 changes: 2 additions & 1 deletion src/cortex-tui/src/external_editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ pub fn get_editor() -> Result<String, EditorError> {
}
}

// Fallback
// Fallback for Linux and other Unix-like targets.
#[cfg(not(any(target_os = "windows", target_os = "macos")))]
Ok("vi".to_string())
}

Expand Down