|
|
|
@ -94,6 +94,12 @@ impl Options {
|
|
|
|
|
DistantSubcommand::Client(cmd) => {
|
|
|
|
|
update_logging!(client);
|
|
|
|
|
match cmd {
|
|
|
|
|
ClientSubcommand::Api {
|
|
|
|
|
network, timeout, ..
|
|
|
|
|
} => {
|
|
|
|
|
network.merge(config.client.network);
|
|
|
|
|
*timeout = timeout.take().or(config.client.api.timeout);
|
|
|
|
|
}
|
|
|
|
|
ClientSubcommand::Capabilities { network, .. } => {
|
|
|
|
|
network.merge(config.client.network);
|
|
|
|
|
}
|
|
|
|
@ -134,12 +140,6 @@ impl Options {
|
|
|
|
|
.take()
|
|
|
|
|
.or(config.client.launch.distant.bind_server);
|
|
|
|
|
}
|
|
|
|
|
ClientSubcommand::Repl {
|
|
|
|
|
network, timeout, ..
|
|
|
|
|
} => {
|
|
|
|
|
network.merge(config.client.network);
|
|
|
|
|
*timeout = timeout.take().or(config.client.repl.timeout);
|
|
|
|
|
}
|
|
|
|
|
ClientSubcommand::Shell { network, .. } => {
|
|
|
|
|
network.merge(config.client.network);
|
|
|
|
|
}
|
|
|
|
@ -236,6 +236,29 @@ pub enum DistantSubcommand {
|
|
|
|
|
/// Subcommands for `distant client`.
|
|
|
|
|
#[derive(Debug, PartialEq, Subcommand, IsVariant)]
|
|
|
|
|
pub enum ClientSubcommand {
|
|
|
|
|
/// Listen over stdin & stdout to communicate with a distant server using the JSON lines API
|
|
|
|
|
Api {
|
|
|
|
|
/// Location to store cached data
|
|
|
|
|
#[clap(
|
|
|
|
|
long,
|
|
|
|
|
value_hint = ValueHint::FilePath,
|
|
|
|
|
value_parser,
|
|
|
|
|
default_value = CACHE_FILE_PATH_STR.as_str()
|
|
|
|
|
)]
|
|
|
|
|
cache: PathBuf,
|
|
|
|
|
|
|
|
|
|
/// Represents the maximum time (in seconds) to wait for a network request before timing out.
|
|
|
|
|
#[clap(long)]
|
|
|
|
|
timeout: Option<f32>,
|
|
|
|
|
|
|
|
|
|
/// Specify a connection being managed
|
|
|
|
|
#[clap(long)]
|
|
|
|
|
connection: Option<ConnectionId>,
|
|
|
|
|
|
|
|
|
|
#[clap(flatten)]
|
|
|
|
|
network: NetworkSettings,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/// Retrieves capabilities of the remote server
|
|
|
|
|
Capabilities {
|
|
|
|
|
/// Location to store cached data
|
|
|
|
@ -341,33 +364,6 @@ pub enum ClientSubcommand {
|
|
|
|
|
destination: Box<Destination>,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/// Runs actions in a read-eval-print loop
|
|
|
|
|
Repl {
|
|
|
|
|
/// Location to store cached data
|
|
|
|
|
#[clap(
|
|
|
|
|
long,
|
|
|
|
|
value_hint = ValueHint::FilePath,
|
|
|
|
|
value_parser,
|
|
|
|
|
default_value = CACHE_FILE_PATH_STR.as_str()
|
|
|
|
|
)]
|
|
|
|
|
cache: PathBuf,
|
|
|
|
|
|
|
|
|
|
/// Represents the maximum time (in seconds) to wait for a network request before timing out.
|
|
|
|
|
#[clap(long)]
|
|
|
|
|
timeout: Option<f32>,
|
|
|
|
|
|
|
|
|
|
/// Specify a connection being managed
|
|
|
|
|
#[clap(long)]
|
|
|
|
|
connection: Option<ConnectionId>,
|
|
|
|
|
|
|
|
|
|
#[clap(flatten)]
|
|
|
|
|
network: NetworkSettings,
|
|
|
|
|
|
|
|
|
|
/// Format used for input into and output from the repl
|
|
|
|
|
#[clap(short, long, default_value_t, value_enum)]
|
|
|
|
|
format: Format,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/// Specialized treatment of running a remote shell process
|
|
|
|
|
Shell {
|
|
|
|
|
/// Location to store cached data
|
|
|
|
@ -465,7 +461,7 @@ impl ClientSubcommand {
|
|
|
|
|
Self::Connect { cache, .. } => cache.as_path(),
|
|
|
|
|
Self::FileSystem(fs) => fs.cache_path(),
|
|
|
|
|
Self::Launch { cache, .. } => cache.as_path(),
|
|
|
|
|
Self::Repl { cache, .. } => cache.as_path(),
|
|
|
|
|
Self::Api { cache, .. } => cache.as_path(),
|
|
|
|
|
Self::Shell { cache, .. } => cache.as_path(),
|
|
|
|
|
Self::Spawn { cache, .. } => cache.as_path(),
|
|
|
|
|
Self::SystemInfo { cache, .. } => cache.as_path(),
|
|
|
|
@ -478,7 +474,7 @@ impl ClientSubcommand {
|
|
|
|
|
Self::Connect { network, .. } => network,
|
|
|
|
|
Self::FileSystem(fs) => fs.network_settings(),
|
|
|
|
|
Self::Launch { network, .. } => network,
|
|
|
|
|
Self::Repl { network, .. } => network,
|
|
|
|
|
Self::Api { network, .. } => network,
|
|
|
|
|
Self::Shell { network, .. } => network,
|
|
|
|
|
Self::Spawn { network, .. } => network,
|
|
|
|
|
Self::SystemInfo { network, .. } => network,
|
|
|
|
@ -1114,21 +1110,21 @@ mod tests {
|
|
|
|
|
use std::time::Duration;
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn distant_capabilities_should_support_merging_with_config() {
|
|
|
|
|
fn distant_api_should_support_merging_with_config() {
|
|
|
|
|
let mut options = Options {
|
|
|
|
|
config_path: None,
|
|
|
|
|
logging: LoggingSettings {
|
|
|
|
|
log_file: None,
|
|
|
|
|
log_level: None,
|
|
|
|
|
},
|
|
|
|
|
command: DistantSubcommand::Client(ClientSubcommand::Capabilities {
|
|
|
|
|
command: DistantSubcommand::Client(ClientSubcommand::Api {
|
|
|
|
|
cache: PathBuf::new(),
|
|
|
|
|
connection: None,
|
|
|
|
|
network: NetworkSettings {
|
|
|
|
|
unix_socket: None,
|
|
|
|
|
windows_pipe: None,
|
|
|
|
|
},
|
|
|
|
|
format: Format::Json,
|
|
|
|
|
timeout: None,
|
|
|
|
|
}),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -1142,9 +1138,7 @@ mod tests {
|
|
|
|
|
unix_socket: Some(PathBuf::from("config-unix-socket")),
|
|
|
|
|
windows_pipe: Some(String::from("config-windows-pipe")),
|
|
|
|
|
},
|
|
|
|
|
connect: ClientConnectConfig {
|
|
|
|
|
options: map!("hello" -> "world"),
|
|
|
|
|
},
|
|
|
|
|
api: ClientApiConfig { timeout: Some(5.0) },
|
|
|
|
|
..Default::default()
|
|
|
|
|
},
|
|
|
|
|
..Default::default()
|
|
|
|
@ -1158,35 +1152,35 @@ mod tests {
|
|
|
|
|
log_file: Some(PathBuf::from("config-log-file")),
|
|
|
|
|
log_level: Some(LogLevel::Trace),
|
|
|
|
|
},
|
|
|
|
|
command: DistantSubcommand::Client(ClientSubcommand::Capabilities {
|
|
|
|
|
command: DistantSubcommand::Client(ClientSubcommand::Api {
|
|
|
|
|
cache: PathBuf::new(),
|
|
|
|
|
connection: None,
|
|
|
|
|
network: NetworkSettings {
|
|
|
|
|
unix_socket: Some(PathBuf::from("config-unix-socket")),
|
|
|
|
|
windows_pipe: Some(String::from("config-windows-pipe")),
|
|
|
|
|
},
|
|
|
|
|
format: Format::Json,
|
|
|
|
|
timeout: Some(5.0),
|
|
|
|
|
}),
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn distant_capabilities_should_prioritize_explicit_cli_options_when_merging() {
|
|
|
|
|
fn distant_api_should_prioritize_explicit_cli_options_when_merging() {
|
|
|
|
|
let mut options = Options {
|
|
|
|
|
config_path: None,
|
|
|
|
|
logging: LoggingSettings {
|
|
|
|
|
log_file: Some(PathBuf::from("cli-log-file")),
|
|
|
|
|
log_level: Some(LogLevel::Info),
|
|
|
|
|
},
|
|
|
|
|
command: DistantSubcommand::Client(ClientSubcommand::Capabilities {
|
|
|
|
|
command: DistantSubcommand::Client(ClientSubcommand::Api {
|
|
|
|
|
cache: PathBuf::new(),
|
|
|
|
|
connection: None,
|
|
|
|
|
network: NetworkSettings {
|
|
|
|
|
unix_socket: Some(PathBuf::from("cli-unix-socket")),
|
|
|
|
|
windows_pipe: Some(String::from("cli-windows-pipe")),
|
|
|
|
|
},
|
|
|
|
|
format: Format::Json,
|
|
|
|
|
timeout: Some(99.0),
|
|
|
|
|
}),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -1200,9 +1194,7 @@ mod tests {
|
|
|
|
|
unix_socket: Some(PathBuf::from("config-unix-socket")),
|
|
|
|
|
windows_pipe: Some(String::from("config-windows-pipe")),
|
|
|
|
|
},
|
|
|
|
|
connect: ClientConnectConfig {
|
|
|
|
|
options: map!("hello" -> "world", "config" -> "value"),
|
|
|
|
|
},
|
|
|
|
|
api: ClientApiConfig { timeout: Some(5.0) },
|
|
|
|
|
..Default::default()
|
|
|
|
|
},
|
|
|
|
|
..Default::default()
|
|
|
|
@ -1216,36 +1208,35 @@ mod tests {
|
|
|
|
|
log_file: Some(PathBuf::from("cli-log-file")),
|
|
|
|
|
log_level: Some(LogLevel::Info),
|
|
|
|
|
},
|
|
|
|
|
command: DistantSubcommand::Client(ClientSubcommand::Capabilities {
|
|
|
|
|
command: DistantSubcommand::Client(ClientSubcommand::Api {
|
|
|
|
|
cache: PathBuf::new(),
|
|
|
|
|
connection: None,
|
|
|
|
|
network: NetworkSettings {
|
|
|
|
|
unix_socket: Some(PathBuf::from("cli-unix-socket")),
|
|
|
|
|
windows_pipe: Some(String::from("cli-windows-pipe")),
|
|
|
|
|
},
|
|
|
|
|
format: Format::Json,
|
|
|
|
|
timeout: Some(99.0),
|
|
|
|
|
}),
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn distant_connect_should_support_merging_with_config() {
|
|
|
|
|
fn distant_capabilities_should_support_merging_with_config() {
|
|
|
|
|
let mut options = Options {
|
|
|
|
|
config_path: None,
|
|
|
|
|
logging: LoggingSettings {
|
|
|
|
|
log_file: None,
|
|
|
|
|
log_level: None,
|
|
|
|
|
},
|
|
|
|
|
command: DistantSubcommand::Client(ClientSubcommand::Connect {
|
|
|
|
|
command: DistantSubcommand::Client(ClientSubcommand::Capabilities {
|
|
|
|
|
cache: PathBuf::new(),
|
|
|
|
|
options: map!(),
|
|
|
|
|
connection: None,
|
|
|
|
|
network: NetworkSettings {
|
|
|
|
|
unix_socket: None,
|
|
|
|
|
windows_pipe: None,
|
|
|
|
|
},
|
|
|
|
|
format: Format::Json,
|
|
|
|
|
destination: Box::new("test://destination".parse().unwrap()),
|
|
|
|
|
}),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -1275,37 +1266,35 @@ mod tests {
|
|
|
|
|
log_file: Some(PathBuf::from("config-log-file")),
|
|
|
|
|
log_level: Some(LogLevel::Trace),
|
|
|
|
|
},
|
|
|
|
|
command: DistantSubcommand::Client(ClientSubcommand::Connect {
|
|
|
|
|
command: DistantSubcommand::Client(ClientSubcommand::Capabilities {
|
|
|
|
|
cache: PathBuf::new(),
|
|
|
|
|
options: map!("hello" -> "world"),
|
|
|
|
|
connection: None,
|
|
|
|
|
network: NetworkSettings {
|
|
|
|
|
unix_socket: Some(PathBuf::from("config-unix-socket")),
|
|
|
|
|
windows_pipe: Some(String::from("config-windows-pipe")),
|
|
|
|
|
},
|
|
|
|
|
format: Format::Json,
|
|
|
|
|
destination: Box::new("test://destination".parse().unwrap()),
|
|
|
|
|
}),
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn distant_connect_should_prioritize_explicit_cli_options_when_merging() {
|
|
|
|
|
fn distant_capabilities_should_prioritize_explicit_cli_options_when_merging() {
|
|
|
|
|
let mut options = Options {
|
|
|
|
|
config_path: None,
|
|
|
|
|
logging: LoggingSettings {
|
|
|
|
|
log_file: Some(PathBuf::from("cli-log-file")),
|
|
|
|
|
log_level: Some(LogLevel::Info),
|
|
|
|
|
},
|
|
|
|
|
command: DistantSubcommand::Client(ClientSubcommand::Connect {
|
|
|
|
|
command: DistantSubcommand::Client(ClientSubcommand::Capabilities {
|
|
|
|
|
cache: PathBuf::new(),
|
|
|
|
|
options: map!("hello" -> "test", "cli" -> "value"),
|
|
|
|
|
connection: None,
|
|
|
|
|
network: NetworkSettings {
|
|
|
|
|
unix_socket: Some(PathBuf::from("cli-unix-socket")),
|
|
|
|
|
windows_pipe: Some(String::from("cli-windows-pipe")),
|
|
|
|
|
},
|
|
|
|
|
format: Format::Json,
|
|
|
|
|
destination: Box::new("test://destination".parse().unwrap()),
|
|
|
|
|
}),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -1335,33 +1324,29 @@ mod tests {
|
|
|
|
|
log_file: Some(PathBuf::from("cli-log-file")),
|
|
|
|
|
log_level: Some(LogLevel::Info),
|
|
|
|
|
},
|
|
|
|
|
command: DistantSubcommand::Client(ClientSubcommand::Connect {
|
|
|
|
|
command: DistantSubcommand::Client(ClientSubcommand::Capabilities {
|
|
|
|
|
cache: PathBuf::new(),
|
|
|
|
|
options: map!("hello" -> "test", "cli" -> "value", "config" -> "value"),
|
|
|
|
|
connection: None,
|
|
|
|
|
network: NetworkSettings {
|
|
|
|
|
unix_socket: Some(PathBuf::from("cli-unix-socket")),
|
|
|
|
|
windows_pipe: Some(String::from("cli-windows-pipe")),
|
|
|
|
|
},
|
|
|
|
|
format: Format::Json,
|
|
|
|
|
destination: Box::new("test://destination".parse().unwrap()),
|
|
|
|
|
}),
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn distant_launch_should_support_merging_with_config() {
|
|
|
|
|
fn distant_connect_should_support_merging_with_config() {
|
|
|
|
|
let mut options = Options {
|
|
|
|
|
config_path: None,
|
|
|
|
|
logging: LoggingSettings {
|
|
|
|
|
log_file: None,
|
|
|
|
|
log_level: None,
|
|
|
|
|
},
|
|
|
|
|
command: DistantSubcommand::Client(ClientSubcommand::Launch {
|
|
|
|
|
command: DistantSubcommand::Client(ClientSubcommand::Connect {
|
|
|
|
|
cache: PathBuf::new(),
|
|
|
|
|
distant_bin: None,
|
|
|
|
|
distant_bind_server: None,
|
|
|
|
|
distant_args: None,
|
|
|
|
|
options: map!(),
|
|
|
|
|
network: NetworkSettings {
|
|
|
|
|
unix_socket: None,
|
|
|
|
@ -1382,14 +1367,7 @@ mod tests {
|
|
|
|
|
unix_socket: Some(PathBuf::from("config-unix-socket")),
|
|
|
|
|
windows_pipe: Some(String::from("config-windows-pipe")),
|
|
|
|
|
},
|
|
|
|
|
launch: ClientLaunchConfig {
|
|
|
|
|
distant: ClientLaunchDistantConfig {
|
|
|
|
|
args: Some(String::from("config-args")),
|
|
|
|
|
bin: Some(String::from("config-bin")),
|
|
|
|
|
bind_server: Some(BindAddress::Host(Host::Name(String::from(
|
|
|
|
|
"config-host",
|
|
|
|
|
)))),
|
|
|
|
|
},
|
|
|
|
|
connect: ClientConnectConfig {
|
|
|
|
|
options: map!("hello" -> "world"),
|
|
|
|
|
},
|
|
|
|
|
..Default::default()
|
|
|
|
@ -1405,13 +1383,8 @@ mod tests {
|
|
|
|
|
log_file: Some(PathBuf::from("config-log-file")),
|
|
|
|
|
log_level: Some(LogLevel::Trace),
|
|
|
|
|
},
|
|
|
|
|
command: DistantSubcommand::Client(ClientSubcommand::Launch {
|
|
|
|
|
command: DistantSubcommand::Client(ClientSubcommand::Connect {
|
|
|
|
|
cache: PathBuf::new(),
|
|
|
|
|
distant_args: Some(String::from("config-args")),
|
|
|
|
|
distant_bin: Some(String::from("config-bin")),
|
|
|
|
|
distant_bind_server: Some(BindAddress::Host(Host::Name(String::from(
|
|
|
|
|
"config-host",
|
|
|
|
|
)))),
|
|
|
|
|
options: map!("hello" -> "world"),
|
|
|
|
|
network: NetworkSettings {
|
|
|
|
|
unix_socket: Some(PathBuf::from("config-unix-socket")),
|
|
|
|
@ -1425,18 +1398,15 @@ mod tests {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn distant_launch_should_prioritize_explicit_cli_options_when_merging() {
|
|
|
|
|
fn distant_connect_should_prioritize_explicit_cli_options_when_merging() {
|
|
|
|
|
let mut options = Options {
|
|
|
|
|
config_path: None,
|
|
|
|
|
logging: LoggingSettings {
|
|
|
|
|
log_file: Some(PathBuf::from("cli-log-file")),
|
|
|
|
|
log_level: Some(LogLevel::Info),
|
|
|
|
|
},
|
|
|
|
|
command: DistantSubcommand::Client(ClientSubcommand::Launch {
|
|
|
|
|
command: DistantSubcommand::Client(ClientSubcommand::Connect {
|
|
|
|
|
cache: PathBuf::new(),
|
|
|
|
|
distant_args: Some(String::from("cli-args")),
|
|
|
|
|
distant_bin: Some(String::from("cli-bin")),
|
|
|
|
|
distant_bind_server: Some(BindAddress::Host(Host::Name(String::from("cli-host")))),
|
|
|
|
|
options: map!("hello" -> "test", "cli" -> "value"),
|
|
|
|
|
network: NetworkSettings {
|
|
|
|
|
unix_socket: Some(PathBuf::from("cli-unix-socket")),
|
|
|
|
@ -1457,14 +1427,7 @@ mod tests {
|
|
|
|
|
unix_socket: Some(PathBuf::from("config-unix-socket")),
|
|
|
|
|
windows_pipe: Some(String::from("config-windows-pipe")),
|
|
|
|
|
},
|
|
|
|
|
launch: ClientLaunchConfig {
|
|
|
|
|
distant: ClientLaunchDistantConfig {
|
|
|
|
|
args: Some(String::from("config-args")),
|
|
|
|
|
bin: Some(String::from("config-bin")),
|
|
|
|
|
bind_server: Some(BindAddress::Host(Host::Name(String::from(
|
|
|
|
|
"config-host",
|
|
|
|
|
)))),
|
|
|
|
|
},
|
|
|
|
|
connect: ClientConnectConfig {
|
|
|
|
|
options: map!("hello" -> "world", "config" -> "value"),
|
|
|
|
|
},
|
|
|
|
|
..Default::default()
|
|
|
|
@ -1480,14 +1443,9 @@ mod tests {
|
|
|
|
|
log_file: Some(PathBuf::from("cli-log-file")),
|
|
|
|
|
log_level: Some(LogLevel::Info),
|
|
|
|
|
},
|
|
|
|
|
command: DistantSubcommand::Client(ClientSubcommand::Launch {
|
|
|
|
|
command: DistantSubcommand::Client(ClientSubcommand::Connect {
|
|
|
|
|
cache: PathBuf::new(),
|
|
|
|
|
distant_args: Some(String::from("cli-args")),
|
|
|
|
|
distant_bin: Some(String::from("cli-bin")),
|
|
|
|
|
distant_bind_server: Some(BindAddress::Host(Host::Name(String::from(
|
|
|
|
|
"cli-host",
|
|
|
|
|
)))),
|
|
|
|
|
options: map!("hello" -> "test", "config" -> "value", "cli" -> "value"),
|
|
|
|
|
options: map!("hello" -> "test", "cli" -> "value", "config" -> "value"),
|
|
|
|
|
network: NetworkSettings {
|
|
|
|
|
unix_socket: Some(PathBuf::from("cli-unix-socket")),
|
|
|
|
|
windows_pipe: Some(String::from("cli-windows-pipe")),
|
|
|
|
@ -1500,22 +1458,25 @@ mod tests {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn distant_repl_should_support_merging_with_config() {
|
|
|
|
|
fn distant_launch_should_support_merging_with_config() {
|
|
|
|
|
let mut options = Options {
|
|
|
|
|
config_path: None,
|
|
|
|
|
logging: LoggingSettings {
|
|
|
|
|
log_file: None,
|
|
|
|
|
log_level: None,
|
|
|
|
|
},
|
|
|
|
|
command: DistantSubcommand::Client(ClientSubcommand::Repl {
|
|
|
|
|
command: DistantSubcommand::Client(ClientSubcommand::Launch {
|
|
|
|
|
cache: PathBuf::new(),
|
|
|
|
|
connection: None,
|
|
|
|
|
format: Format::Json,
|
|
|
|
|
distant_bin: None,
|
|
|
|
|
distant_bind_server: None,
|
|
|
|
|
distant_args: None,
|
|
|
|
|
options: map!(),
|
|
|
|
|
network: NetworkSettings {
|
|
|
|
|
unix_socket: None,
|
|
|
|
|
windows_pipe: None,
|
|
|
|
|
},
|
|
|
|
|
timeout: None,
|
|
|
|
|
format: Format::Json,
|
|
|
|
|
destination: Box::new("test://destination".parse().unwrap()),
|
|
|
|
|
}),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -1529,7 +1490,16 @@ mod tests {
|
|
|
|
|
unix_socket: Some(PathBuf::from("config-unix-socket")),
|
|
|
|
|
windows_pipe: Some(String::from("config-windows-pipe")),
|
|
|
|
|
},
|
|
|
|
|
repl: ClientReplConfig { timeout: Some(5.0) },
|
|
|
|
|
launch: ClientLaunchConfig {
|
|
|
|
|
distant: ClientLaunchDistantConfig {
|
|
|
|
|
args: Some(String::from("config-args")),
|
|
|
|
|
bin: Some(String::from("config-bin")),
|
|
|
|
|
bind_server: Some(BindAddress::Host(Host::Name(String::from(
|
|
|
|
|
"config-host",
|
|
|
|
|
)))),
|
|
|
|
|
},
|
|
|
|
|
options: map!("hello" -> "world"),
|
|
|
|
|
},
|
|
|
|
|
..Default::default()
|
|
|
|
|
},
|
|
|
|
|
..Default::default()
|
|
|
|
@ -1543,37 +1513,45 @@ mod tests {
|
|
|
|
|
log_file: Some(PathBuf::from("config-log-file")),
|
|
|
|
|
log_level: Some(LogLevel::Trace),
|
|
|
|
|
},
|
|
|
|
|
command: DistantSubcommand::Client(ClientSubcommand::Repl {
|
|
|
|
|
command: DistantSubcommand::Client(ClientSubcommand::Launch {
|
|
|
|
|
cache: PathBuf::new(),
|
|
|
|
|
connection: None,
|
|
|
|
|
format: Format::Json,
|
|
|
|
|
distant_args: Some(String::from("config-args")),
|
|
|
|
|
distant_bin: Some(String::from("config-bin")),
|
|
|
|
|
distant_bind_server: Some(BindAddress::Host(Host::Name(String::from(
|
|
|
|
|
"config-host",
|
|
|
|
|
)))),
|
|
|
|
|
options: map!("hello" -> "world"),
|
|
|
|
|
network: NetworkSettings {
|
|
|
|
|
unix_socket: Some(PathBuf::from("config-unix-socket")),
|
|
|
|
|
windows_pipe: Some(String::from("config-windows-pipe")),
|
|
|
|
|
},
|
|
|
|
|
timeout: Some(5.0),
|
|
|
|
|
format: Format::Json,
|
|
|
|
|
destination: Box::new("test://destination".parse().unwrap()),
|
|
|
|
|
}),
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn distant_repl_should_prioritize_explicit_cli_options_when_merging() {
|
|
|
|
|
fn distant_launch_should_prioritize_explicit_cli_options_when_merging() {
|
|
|
|
|
let mut options = Options {
|
|
|
|
|
config_path: None,
|
|
|
|
|
logging: LoggingSettings {
|
|
|
|
|
log_file: Some(PathBuf::from("cli-log-file")),
|
|
|
|
|
log_level: Some(LogLevel::Info),
|
|
|
|
|
},
|
|
|
|
|
command: DistantSubcommand::Client(ClientSubcommand::Repl {
|
|
|
|
|
command: DistantSubcommand::Client(ClientSubcommand::Launch {
|
|
|
|
|
cache: PathBuf::new(),
|
|
|
|
|
connection: None,
|
|
|
|
|
format: Format::Json,
|
|
|
|
|
distant_args: Some(String::from("cli-args")),
|
|
|
|
|
distant_bin: Some(String::from("cli-bin")),
|
|
|
|
|
distant_bind_server: Some(BindAddress::Host(Host::Name(String::from("cli-host")))),
|
|
|
|
|
options: map!("hello" -> "test", "cli" -> "value"),
|
|
|
|
|
network: NetworkSettings {
|
|
|
|
|
unix_socket: Some(PathBuf::from("cli-unix-socket")),
|
|
|
|
|
windows_pipe: Some(String::from("cli-windows-pipe")),
|
|
|
|
|
},
|
|
|
|
|
timeout: Some(99.0),
|
|
|
|
|
format: Format::Json,
|
|
|
|
|
destination: Box::new("test://destination".parse().unwrap()),
|
|
|
|
|
}),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -1587,7 +1565,16 @@ mod tests {
|
|
|
|
|
unix_socket: Some(PathBuf::from("config-unix-socket")),
|
|
|
|
|
windows_pipe: Some(String::from("config-windows-pipe")),
|
|
|
|
|
},
|
|
|
|
|
repl: ClientReplConfig { timeout: Some(5.0) },
|
|
|
|
|
launch: ClientLaunchConfig {
|
|
|
|
|
distant: ClientLaunchDistantConfig {
|
|
|
|
|
args: Some(String::from("config-args")),
|
|
|
|
|
bin: Some(String::from("config-bin")),
|
|
|
|
|
bind_server: Some(BindAddress::Host(Host::Name(String::from(
|
|
|
|
|
"config-host",
|
|
|
|
|
)))),
|
|
|
|
|
},
|
|
|
|
|
options: map!("hello" -> "world", "config" -> "value"),
|
|
|
|
|
},
|
|
|
|
|
..Default::default()
|
|
|
|
|
},
|
|
|
|
|
..Default::default()
|
|
|
|
@ -1601,15 +1588,20 @@ mod tests {
|
|
|
|
|
log_file: Some(PathBuf::from("cli-log-file")),
|
|
|
|
|
log_level: Some(LogLevel::Info),
|
|
|
|
|
},
|
|
|
|
|
command: DistantSubcommand::Client(ClientSubcommand::Repl {
|
|
|
|
|
command: DistantSubcommand::Client(ClientSubcommand::Launch {
|
|
|
|
|
cache: PathBuf::new(),
|
|
|
|
|
connection: None,
|
|
|
|
|
format: Format::Json,
|
|
|
|
|
distant_args: Some(String::from("cli-args")),
|
|
|
|
|
distant_bin: Some(String::from("cli-bin")),
|
|
|
|
|
distant_bind_server: Some(BindAddress::Host(Host::Name(String::from(
|
|
|
|
|
"cli-host",
|
|
|
|
|
)))),
|
|
|
|
|
options: map!("hello" -> "test", "config" -> "value", "cli" -> "value"),
|
|
|
|
|
network: NetworkSettings {
|
|
|
|
|
unix_socket: Some(PathBuf::from("cli-unix-socket")),
|
|
|
|
|
windows_pipe: Some(String::from("cli-windows-pipe")),
|
|
|
|
|
},
|
|
|
|
|
timeout: Some(99.0),
|
|
|
|
|
format: Format::Json,
|
|
|
|
|
destination: Box::new("test://destination".parse().unwrap()),
|
|
|
|
|
}),
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|