Rename detached to persist (#94)

pull/98/head
Chip Senkbeil 2 years ago committed by GitHub
parent 2e482ea20e
commit 0308343794
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Update ProcStdin, ProcStdout, and ProcStderr to use list of bytes instead
of a string as a parameter; RemoteProcess and RemoteLspProcess now support
reading and writing using either `String` or `Vec<u8>`
- Rename `--detached` and associated to `--persist`
### Removed
- Github actions no longer use paths-filter so every PR & commit will test

@ -30,10 +30,10 @@ impl RemoteLspProcess {
channel: SessionChannel,
cmd: impl Into<String>,
args: Vec<String>,
detached: bool,
persist: bool,
pty: Option<PtySize>,
) -> Result<Self, RemoteProcessError> {
let mut inner = RemoteProcess::spawn(tenant, channel, cmd, args, detached, pty).await?;
let mut inner = RemoteProcess::spawn(tenant, channel, cmd, args, persist, pty).await?;
let stdin = inner.stdin.take().map(RemoteLspStdin::new);
let stdout = inner.stdout.take().map(RemoteLspStdout::new);
let stderr = inner.stderr.take().map(RemoteLspStderr::new);

@ -81,7 +81,7 @@ impl RemoteProcess {
mut channel: SessionChannel,
cmd: impl Into<String>,
args: Vec<String>,
detached: bool,
persist: bool,
pty: Option<PtySize>,
) -> Result<Self, RemoteProcessError> {
let tenant = tenant.into();
@ -94,7 +94,7 @@ impl RemoteProcess {
vec![RequestData::ProcSpawn {
cmd,
args,
detached,
persist,
pty,
}],
))

@ -124,7 +124,7 @@ pub trait SessionChannelExt {
tenant: impl Into<String>,
cmd: impl Into<String>,
args: Vec<impl Into<String>>,
detached: bool,
persist: bool,
pty: Option<PtySize>,
) -> AsyncReturn<'_, RemoteProcess, RemoteProcessError>;
@ -134,7 +134,7 @@ pub trait SessionChannelExt {
tenant: impl Into<String>,
cmd: impl Into<String>,
args: Vec<impl Into<String>>,
detached: bool,
persist: bool,
pty: Option<PtySize>,
) -> AsyncReturn<'_, RemoteLspProcess, RemoteProcessError>;
@ -379,14 +379,14 @@ impl SessionChannelExt for SessionChannel {
tenant: impl Into<String>,
cmd: impl Into<String>,
args: Vec<impl Into<String>>,
detached: bool,
persist: bool,
pty: Option<PtySize>,
) -> AsyncReturn<'_, RemoteProcess, RemoteProcessError> {
let tenant = tenant.into();
let cmd = cmd.into();
let args = args.into_iter().map(Into::into).collect();
Box::pin(async move {
RemoteProcess::spawn(tenant, self.clone(), cmd, args, detached, pty).await
RemoteProcess::spawn(tenant, self.clone(), cmd, args, persist, pty).await
})
}
@ -395,14 +395,14 @@ impl SessionChannelExt for SessionChannel {
tenant: impl Into<String>,
cmd: impl Into<String>,
args: Vec<impl Into<String>>,
detached: bool,
persist: bool,
pty: Option<PtySize>,
) -> AsyncReturn<'_, RemoteLspProcess, RemoteProcessError> {
let tenant = tenant.into();
let cmd = cmd.into();
let args = args.into_iter().map(Into::into).collect();
Box::pin(async move {
RemoteLspProcess::spawn(tenant, self.clone(), cmd, args, detached, pty).await
RemoteLspProcess::spawn(tenant, self.clone(), cmd, args, persist, pty).await
})
}

@ -219,10 +219,10 @@ pub enum RequestData {
/// Arguments for the command
args: Vec<String>,
/// Whether or not the process should be detached, meaning that the process will not be
/// Whether or not the process should be persistent, meaning that the process will not be
/// killed when the associated client disconnects
#[cfg_attr(feature = "structopt", structopt(long))]
detached: bool,
persist: bool,
/// If provided, will spawn process in a pty, otherwise spawns directly
#[cfg_attr(feature = "structopt", structopt(long))]
@ -617,8 +617,8 @@ pub struct RunningProcess {
/// Arguments for the command
pub args: Vec<String>,
/// Whether or not the process was run in detached mode
pub detached: bool,
/// Whether or not the process was run in persist mode
pub persist: bool,
/// Pty associated with running process if it has one
pub pty: Option<PtySize>,

@ -101,9 +101,9 @@ pub(super) async fn process(
RequestData::ProcSpawn {
cmd,
args,
detached,
persist,
pty,
} => proc_spawn(conn_id, state, reply, cmd, args, detached, pty).await,
} => proc_spawn(conn_id, state, reply, cmd, args, persist, pty).await,
RequestData::ProcKill { id } => proc_kill(conn_id, state, id).await,
RequestData::ProcStdin { id, data } => proc_stdin(conn_id, state, id, data).await,
RequestData::ProcResizePty { id, size } => {
@ -433,7 +433,7 @@ async fn proc_spawn<F>(
reply: F,
cmd: String,
args: Vec<String>,
detached: bool,
persist: bool,
pty: Option<PtySize>,
) -> Result<Outgoing, ServerError>
where
@ -544,7 +544,7 @@ where
ProcessState {
cmd,
args,
detached,
persist,
id,
stdin,
killer,
@ -632,7 +632,7 @@ async fn proc_list(state: HState) -> Result<Outgoing, ServerError> {
.map(|p| RunningProcess {
cmd: p.cmd.to_string(),
args: p.args.clone(),
detached: p.detached,
persist: p.persist,
// TODO: Support retrieving current pty size
pty: None,
id: p.id,
@ -2143,7 +2143,7 @@ mod tests {
vec![RequestData::ProcSpawn {
cmd: DOES_NOT_EXIST_BIN.to_str().unwrap().to_string(),
args: Vec::new(),
detached: false,
persist: false,
pty: None,
}],
);
@ -2170,7 +2170,7 @@ mod tests {
vec![RequestData::ProcSpawn {
cmd: SCRIPT_RUNNER.to_string(),
args: vec![ECHO_ARGS_TO_STDOUT_SH.to_str().unwrap().to_string()],
detached: false,
persist: false,
pty: None,
}],
);
@ -2204,7 +2204,7 @@ mod tests {
ECHO_ARGS_TO_STDOUT_SH.to_str().unwrap().to_string(),
String::from("some stdout"),
],
detached: false,
persist: false,
pty: None,
}],
);
@ -2271,7 +2271,7 @@ mod tests {
ECHO_ARGS_TO_STDERR_SH.to_str().unwrap().to_string(),
String::from("some stderr"),
],
detached: false,
persist: false,
pty: None,
}],
);
@ -2335,7 +2335,7 @@ mod tests {
vec![RequestData::ProcSpawn {
cmd: SCRIPT_RUNNER.to_string(),
args: vec![SLEEP_SH.to_str().unwrap().to_string(), String::from("0.1")],
detached: false,
persist: false,
pty: None,
}],
);
@ -2379,7 +2379,7 @@ mod tests {
vec![RequestData::ProcSpawn {
cmd: SCRIPT_RUNNER.to_string(),
args: vec![SLEEP_SH.to_str().unwrap().to_string(), String::from("1")],
detached: false,
persist: false,
pty: None,
}],
);
@ -2455,7 +2455,7 @@ mod tests {
vec![RequestData::ProcSpawn {
cmd: SCRIPT_RUNNER.to_string(),
args: vec![SLEEP_SH.to_str().unwrap().to_string(), String::from("1")],
detached: false,
persist: false,
pty: None,
}],
);
@ -2552,7 +2552,7 @@ mod tests {
vec![RequestData::ProcSpawn {
cmd: SCRIPT_RUNNER.to_string(),
args: vec![ECHO_STDIN_TO_STDOUT_SH.to_str().unwrap().to_string()],
detached: false,
persist: false,
pty: None,
}],
);
@ -2626,7 +2626,7 @@ mod tests {
RequestData::ProcSpawn {
cmd: SCRIPT_RUNNER.to_string(),
args: vec![SLEEP_SH.to_str().unwrap().to_string(), String::from("1")],
detached: false,
persist: false,
pty: None,
},
RequestData::ProcList {},
@ -2651,7 +2651,7 @@ mod tests {
entries: vec![RunningProcess {
cmd: SCRIPT_RUNNER.to_string(),
args: vec![SLEEP_SH.to_str().unwrap().to_string(), String::from("1")],
detached: false,
persist: false,
pty: None,
id,
}],

@ -16,7 +16,7 @@ pub struct State {
pub struct ProcessState {
pub cmd: String,
pub args: Vec<String>,
pub detached: bool,
pub persist: bool,
pub id: usize,
pub stdin: Option<Box<dyn InputChannel>>,
@ -68,7 +68,7 @@ impl State {
if let Some(ids) = self.client_processes.remove(&conn_id) {
for id in ids {
if let Some(mut process) = self.processes.remove(&id) {
if !process.detached {
if !process.persist {
trace!(
"<Conn @ {:?}> Requesting proc {} be killed",
conn_id,
@ -83,7 +83,7 @@ impl State {
}
} else {
trace!(
"<Conn @ {:?}> Proc {} is detached and will not be killed",
"<Conn @ {:?}> Proc {} is persistent and will not be killed",
conn_id,
process.id
);

@ -164,22 +164,22 @@ make_api!(
make_api!(
spawn,
RemoteProcess,
{ cmd: String, #[serde(default)] args: Vec<String>, #[serde(default)] pty: Option<PtySize>, #[serde(default)] detached: bool },
{ cmd: String, #[serde(default)] args: Vec<String>, #[serde(default)] pty: Option<PtySize>, #[serde(default)] persist: bool },
|channel, tenant, params| {
channel.spawn(tenant, params.cmd, params.args, params.detached, params.pty).await
channel.spawn(tenant, params.cmd, params.args, params.persist, params.pty).await
}
);
make_api!(
spawn_wait,
Output,
{ cmd: String, #[serde(default)] args: Vec<String>, #[serde(default)] pty: Option<PtySize>, #[serde(default)] detached: bool },
{ cmd: String, #[serde(default)] args: Vec<String>, #[serde(default)] pty: Option<PtySize>, #[serde(default)] persist: bool },
|channel, tenant, params| {
let proc = channel.spawn(
tenant,
params.cmd,
params.args,
params.detached,
params.persist,
params.pty,
).await.to_lua_err()?;
let id = LuaRemoteProcess::from_distant_async(proc).await?.id;
@ -190,9 +190,9 @@ make_api!(
make_api!(
spawn_lsp,
RemoteLspProcess,
{ cmd: String, #[serde(default)] args: Vec<String>, #[serde(default)] pty: Option<PtySize>, #[serde(default)] detached: bool },
{ cmd: String, #[serde(default)] args: Vec<String>, #[serde(default)] pty: Option<PtySize>, #[serde(default)] persist: bool },
|channel, tenant, params| {
channel.spawn_lsp(tenant, params.cmd, params.args, params.detached, params.pty).await
channel.spawn_lsp(tenant, params.cmd, params.args, params.persist, params.pty).await
}
);

@ -35,7 +35,7 @@ struct Process {
id: usize,
cmd: String,
args: Vec<String>,
detached: bool,
persist: bool,
stdin_tx: mpsc::Sender<Vec<u8>>,
kill_tx: mpsc::Sender<()>,
resize_tx: mpsc::Sender<PtySize>,
@ -97,9 +97,9 @@ pub(super) async fn process(
RequestData::ProcSpawn {
cmd,
args,
detached,
persist,
pty,
} => proc_spawn(session, state, cmd, args, detached, pty).await,
} => proc_spawn(session, state, cmd, args, persist, pty).await,
RequestData::ProcResizePty { id, size } => {
proc_resize_pty(session, state, id, size).await
}
@ -614,7 +614,7 @@ async fn proc_spawn(
state: Arc<Mutex<State>>,
cmd: String,
args: Vec<String>,
detached: bool,
persist: bool,
pty: Option<PtySize>,
) -> io::Result<Outgoing> {
let cmd_string = format!("{} {}", cmd, args.join(" "));
@ -642,7 +642,7 @@ async fn proc_spawn(
id,
cmd,
args,
detached,
persist,
stdin_tx: stdin,
kill_tx: killer,
resize_tx: resizer,
@ -722,7 +722,7 @@ async fn proc_list(_session: WezSession, state: Arc<Mutex<State>>) -> io::Result
.map(|p| RunningProcess {
cmd: p.cmd.to_string(),
args: p.args.clone(),
detached: p.detached,
persist: p.persist,
// TODO: Support pty size from ssh
pty: None,
id: p.id,

@ -1355,7 +1355,7 @@ async fn proc_spawn_should_send_error_over_stderr_on_failure(#[future] session:
vec![RequestData::ProcSpawn {
cmd: DOES_NOT_EXIST_BIN.to_str().unwrap().to_string(),
args: Vec::new(),
detached: false,
persist: false,
pty: None,
}],
);
@ -1402,7 +1402,7 @@ async fn proc_spawn_should_send_back_proc_start_on_success(#[future] session: Se
vec![RequestData::ProcSpawn {
cmd: SCRIPT_RUNNER.to_string(),
args: vec![ECHO_ARGS_TO_STDOUT_SH.to_str().unwrap().to_string()],
detached: false,
persist: false,
pty: None,
}],
);
@ -1434,7 +1434,7 @@ async fn proc_spawn_should_send_back_stdout_periodically_when_available(
ECHO_ARGS_TO_STDOUT_SH.to_str().unwrap().to_string(),
String::from("'some stdout'"),
],
detached: false,
persist: false,
pty: None,
}],
);
@ -1501,7 +1501,7 @@ async fn proc_spawn_should_send_back_stderr_periodically_when_available(
ECHO_ARGS_TO_STDERR_SH.to_str().unwrap().to_string(),
String::from("'some stderr'"),
],
detached: false,
persist: false,
pty: None,
}],
);
@ -1563,7 +1563,7 @@ async fn proc_spawn_should_clear_process_from_state_when_done(#[future] session:
vec![RequestData::ProcSpawn {
cmd: SCRIPT_RUNNER.to_string(),
args: vec![SLEEP_SH.to_str().unwrap().to_string(), String::from("0.1")],
detached: false,
persist: false,
pty: None,
}],
);
@ -1612,7 +1612,7 @@ async fn proc_spawn_should_clear_process_from_state_when_killed(#[future] sessio
vec![RequestData::ProcSpawn {
cmd: SCRIPT_RUNNER.to_string(),
args: vec![SLEEP_SH.to_str().unwrap().to_string(), String::from("1")],
detached: false,
persist: false,
pty: None,
}],
);
@ -1687,7 +1687,7 @@ async fn proc_kill_should_send_ok_and_done_responses_on_success(#[future] sessio
vec![RequestData::ProcSpawn {
cmd: SCRIPT_RUNNER.to_string(),
args: vec![SLEEP_SH.to_str().unwrap().to_string(), String::from("1")],
detached: false,
persist: false,
pty: None,
}],
);
@ -1763,7 +1763,7 @@ async fn proc_stdin_should_send_ok_on_success_and_properly_send_stdin_to_process
vec![RequestData::ProcSpawn {
cmd: SCRIPT_RUNNER.to_string(),
args: vec![ECHO_STDIN_TO_STDOUT_SH.to_str().unwrap().to_string()],
detached: false,
persist: false,
pty: None,
}],
);
@ -1813,7 +1813,7 @@ async fn proc_list_should_send_proc_entry_list(#[future] session: Session) {
vec![RequestData::ProcSpawn {
cmd: SCRIPT_RUNNER.to_string(),
args: vec![SLEEP_SH.to_str().unwrap().to_string(), String::from("10")],
detached: false,
persist: false,
pty: None,
}],
);
@ -1839,7 +1839,7 @@ async fn proc_list_should_send_proc_entry_list(#[future] session: Session) {
entries: vec![RunningProcess {
cmd: SCRIPT_RUNNER.to_string(),
args: vec![SLEEP_SH.to_str().unwrap().to_string(), String::from("10")],
detached: false,
persist: false,
pty: None,
id,
}],

@ -677,10 +677,10 @@ pub struct LspSubcommand {
#[structopt(flatten)]
pub ssh_connection: SshConnectionOpts,
/// If provided, will run in detached mode, meaning that the process will not be killed if the
/// If provided, will run in persist mode, meaning that the process will not be killed if the
/// client disconnects from the server
#[structopt(long)]
pub detached: bool,
pub persist: bool,
/// If provided, will run LSP in a pty
#[structopt(long)]
@ -740,10 +740,10 @@ pub struct ShellSubcommand {
#[structopt(flatten)]
pub ssh_connection: SshConnectionOpts,
/// If provided, will run in detached mode, meaning that the process will not be killed if the
/// If provided, will run in persist mode, meaning that the process will not be killed if the
/// client disconnects from the server
#[structopt(long)]
pub detached: bool,
pub persist: bool,
/// Command to run on the remote machine as the shell (defaults to $TERM)
pub cmd: Option<String>,

@ -91,7 +91,7 @@ async fn start(
Some(RequestData::ProcSpawn {
cmd,
args,
detached,
persist,
pty,
}),
) if is_shell_format => {
@ -100,7 +100,7 @@ async fn start(
session.clone_channel(),
cmd,
args,
detached,
persist,
pty,
)
.await?;

@ -74,7 +74,7 @@ async fn start(
session.clone_channel(),
cmd.cmd,
cmd.args,
cmd.detached,
cmd.persist,
if cmd.pty {
terminal_size()
.map(|(Width(width), Height(height))| PtySize::from_rows_and_cols(height, width))

@ -80,7 +80,7 @@ async fn start(
session.clone_channel(),
cmd.cmd.unwrap_or_else(|| "/bin/sh".to_string()),
cmd.args,
cmd.detached,
cmd.persist,
terminal_size().map(|(Width(cols), Height(rows))| PtySize::from_rows_and_cols(rows, cols)),
)
.await?;

@ -171,7 +171,7 @@ fn should_support_json_to_execute_program_and_return_exit_status(mut action_cmd:
payload: vec![RequestData::ProcSpawn {
cmd: SCRIPT_RUNNER.to_string(),
args: vec![ECHO_ARGS_TO_STDOUT_SH.to_str().unwrap().to_string()],
detached: false,
persist: false,
pty: None,
}],
};
@ -205,7 +205,7 @@ fn should_support_json_to_capture_and_print_stdout(ctx: &'_ DistantServerCtx) {
ECHO_ARGS_TO_STDOUT_SH.to_str().unwrap().to_string(),
output.to_string(),
],
detached: false,
persist: false,
pty: None,
}],
};
@ -275,7 +275,7 @@ fn should_support_json_to_capture_and_print_stderr(ctx: &'_ DistantServerCtx) {
ECHO_ARGS_TO_STDERR_SH.to_str().unwrap().to_string(),
output.to_string(),
],
detached: false,
persist: false,
pty: None,
}],
};
@ -341,7 +341,7 @@ fn should_support_json_to_forward_stdin_to_remote_process(ctx: &'_ DistantServer
payload: vec![RequestData::ProcSpawn {
cmd: SCRIPT_RUNNER.to_string(),
args: vec![ECHO_STDIN_TO_STDOUT_SH.to_str().unwrap().to_string()],
detached: false,
persist: false,
pty: None,
}],
};
@ -436,7 +436,7 @@ fn should_support_json_output_for_error(mut action_cmd: Command) {
payload: vec![RequestData::ProcSpawn {
cmd: DOES_NOT_EXIST_BIN.to_str().unwrap().to_string(),
args: Vec::new(),
detached: false,
persist: false,
pty: None,
}],
};

Loading…
Cancel
Save