|
|
@ -90,6 +90,25 @@ fn list() -> io:: Result<()> { |
|
|
|
Ok(()) |
|
|
|
Ok(()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum PROMPT { |
|
|
|
|
|
|
|
YES, |
|
|
|
|
|
|
|
NO |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn get_prompt(question: &str) -> io::Result<PROMPT> { |
|
|
|
|
|
|
|
print!("{} [Y/n] ", question); |
|
|
|
|
|
|
|
io::stdout().flush()?; |
|
|
|
|
|
|
|
let mut input = String::new(); |
|
|
|
|
|
|
|
io::stdin().read_line(&mut input)?; |
|
|
|
|
|
|
|
let input = input.trim().to_lowercase(); |
|
|
|
|
|
|
|
match input.as_str() { |
|
|
|
|
|
|
|
"y" => Ok(PROMPT::YES), |
|
|
|
|
|
|
|
"n" => Ok(PROMPT::NO), |
|
|
|
|
|
|
|
_ => Ok(PROMPT::YES), |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fn main() -> io::Result<()> { |
|
|
|
fn main() -> io::Result<()> { |
|
|
|
let cli = Cli::parse(); |
|
|
|
let cli = Cli::parse(); |
|
|
|
match &cli.command { |
|
|
|
match &cli.command { |
|
|
@ -104,22 +123,14 @@ fn main() -> io::Result<()> { |
|
|
|
} |
|
|
|
} |
|
|
|
None => { |
|
|
|
None => { |
|
|
|
if !is_inited() { |
|
|
|
if !is_inited() { |
|
|
|
print!("Do you want to init your storage? [Y/n] "); |
|
|
|
match get_prompt("Do you want to init your storage?")? { |
|
|
|
io::stdout().flush().expect("Failed to flush stdout"); |
|
|
|
PROMPT::YES => init()?, |
|
|
|
let mut input = String::new(); |
|
|
|
PROMPT::NO => { |
|
|
|
io::stdin() |
|
|
|
|
|
|
|
.read_line(&mut input) |
|
|
|
|
|
|
|
.expect("Failed to read answer"); |
|
|
|
|
|
|
|
let input = input.trim().to_lowercase(); |
|
|
|
|
|
|
|
match input.as_str() { |
|
|
|
|
|
|
|
"y" => init()?, |
|
|
|
|
|
|
|
"n" => { |
|
|
|
|
|
|
|
println!("mps can work only when storage inited."); |
|
|
|
println!("mps can work only when storage inited."); |
|
|
|
println!("Hint: you cant do"); |
|
|
|
println!("Hint: you cant do"); |
|
|
|
println!(" git clone <your_storage_git_url> {}", STORAGE_FOLDER); |
|
|
|
println!(" git clone <your_storage_git_url> {}", STORAGE_FOLDER); |
|
|
|
println!("to init manually your storage and config") |
|
|
|
println!("to init manually your storage and config") |
|
|
|
},
|
|
|
|
},
|
|
|
|
_ => init()?, |
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
println!("login, not implemented yet") |
|
|
|
println!("login, not implemented yet") |
|
|
|