Compare commits
No commits in common. "96ac4d792f2724b2b332f1543b7c6b8af07087f4" and "effe1418eb2b6d274cff4ed93a65df5c27bf9c9c" have entirely different histories.
96ac4d792f
...
effe1418eb
46
src/main.rs
46
src/main.rs
@ -19,7 +19,7 @@ use std::io::Write;
|
|||||||
use std::iter::once;
|
use std::iter::once;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::{env, fs, io};
|
use std::{env, fs};
|
||||||
|
|
||||||
const SERVERS_ENV_VAR: &str = "MSSH_SERVERS";
|
const SERVERS_ENV_VAR: &str = "MSSH_SERVERS";
|
||||||
const EDITOR_ENV_VAR: &str = "MSSH_EDITOR";
|
const EDITOR_ENV_VAR: &str = "MSSH_EDITOR";
|
||||||
@ -119,22 +119,6 @@ enum OldVersionPolicy {
|
|||||||
Delete,
|
Delete,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[macro_export]
|
|
||||||
macro_rules! input {
|
|
||||||
($prompt: tt) => {{
|
|
||||||
print!($prompt);
|
|
||||||
io::stdout().flush().expect("failed to flush stdout");
|
|
||||||
let mut buf = String::new();
|
|
||||||
io::stdin()
|
|
||||||
.read_line(&mut buf)
|
|
||||||
.expect("failed to read stdin");
|
|
||||||
buf.trim().to_string()
|
|
||||||
}};
|
|
||||||
() => {
|
|
||||||
input!()
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() -> Result<(), String> {
|
fn main() -> Result<(), String> {
|
||||||
let args = Args::parse();
|
let args = Args::parse();
|
||||||
|
|
||||||
@ -266,7 +250,13 @@ fn main() -> Result<(), String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !no_confirm {
|
if !no_confirm {
|
||||||
match input!("Continue? [Y|n] ").to_lowercase().as_str() {
|
log!(logger, "Continue? [Y|n] ");
|
||||||
|
std::io::stdout().flush().expect("failed to flush stdout");
|
||||||
|
let mut buffer = String::new();
|
||||||
|
std::io::stdin()
|
||||||
|
.read_line(&mut buffer)
|
||||||
|
.expect("failed to read stdin");
|
||||||
|
match buffer.to_lowercase().trim() {
|
||||||
"n" | "no" => {
|
"n" | "no" => {
|
||||||
log!(logger, "Aborting...");
|
log!(logger, "Aborting...");
|
||||||
return Ok(());
|
return Ok(());
|
||||||
@ -343,7 +333,6 @@ fn main() -> Result<(), String> {
|
|||||||
let file_name = file
|
let file_name = file
|
||||||
.file_name()
|
.file_name()
|
||||||
.ok_or("can only edit files, not directories")?;
|
.ok_or("can only edit files, not directories")?;
|
||||||
'duplicate_check: {
|
|
||||||
if !override_existing
|
if !override_existing
|
||||||
&& fs::read_dir(&working_directory)
|
&& fs::read_dir(&working_directory)
|
||||||
.map_err(|e| format!("failed to open working directory: {e}"))?
|
.map_err(|e| format!("failed to open working directory: {e}"))?
|
||||||
@ -352,27 +341,12 @@ fn main() -> Result<(), String> {
|
|||||||
.iter()
|
.iter()
|
||||||
.any(|entry| entry.file_name() == file_name)
|
.any(|entry| entry.file_name() == file_name)
|
||||||
{
|
{
|
||||||
let duplication_notification = format!(
|
return Err(format!(
|
||||||
"A file with the name {} already exists in {}",
|
"A file with the name {} already exists in {}. You can override it with --override or -f",
|
||||||
file_name.to_string_lossy(),
|
file_name.to_string_lossy(),
|
||||||
working_directory.to_string_lossy()
|
working_directory.to_string_lossy()
|
||||||
);
|
|
||||||
|
|
||||||
if !args.quiet {
|
|
||||||
match input!("{duplication_notification}. Do you want to replace it? [N|y] ")
|
|
||||||
.to_lowercase()
|
|
||||||
.as_str()
|
|
||||||
{
|
|
||||||
"y" | "yes" => break 'duplicate_check,
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Err(format!(
|
|
||||||
"{duplication_notification}. You can override it with --override or -f"
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
require_non_empty_servers(&servers)?;
|
require_non_empty_servers(&servers)?;
|
||||||
start_ssh_agent(&logger)?;
|
start_ssh_agent(&logger)?;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user