Skip to content
Merged
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
3 changes: 1 addition & 2 deletions crates/pilotty-cli/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,7 @@ pub struct SpawnArgs {
#[arg(short, long)]
pub name: Option<String>,

/// Working directory for the spawned process.
/// If omitted, inherits the daemon's current directory.
/// Working directory for the spawned process [default: current directory]
#[arg(long, value_name = "DIR")]
pub cwd: Option<String>,
}
Expand Down
7 changes: 6 additions & 1 deletion crates/pilotty-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ fn cli_to_command(cli: &Cli) -> Option<Command> {
Commands::Spawn(args) => Some(Command::Spawn {
command: args.command.clone(),
session_name: args.name.clone(),
cwd: args.cwd.clone(),
// Default to client's cwd if --cwd not explicitly provided
cwd: args.cwd.clone().or_else(|| {
std::env::current_dir()
.ok()
.map(|p| p.to_string_lossy().into_owned())
}),
}),
Commands::Kill(args) => Some(Command::Kill {
session: args.session.clone(),
Expand Down
6 changes: 3 additions & 3 deletions crates/pilotty-core/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ pub enum Command {
session_name: Option<String>,
/// Working directory for the spawned process.
///
/// If provided, the command runs in this directory. The path must be
/// an existing directory. If not provided, the process inherits the
/// daemon's working directory.
/// The CLI defaults this to the client's current directory. The path
/// must be an existing directory. If not provided by the client, the
/// process inherits the daemon's working directory.
cwd: Option<String>,
},
/// Kill a session.
Expand Down