Add -k flag
This commit is contained in:
@@ -5,7 +5,7 @@ use lazy_static::lazy_static;
|
|||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use shellexpand;
|
use shellexpand;
|
||||||
use std::collections::{BTreeMap, HashMap};
|
use std::collections::{BTreeMap, HashMap};
|
||||||
use std::fs;
|
use std::{env, fs};
|
||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
use toml;
|
use toml;
|
||||||
|
|
||||||
@@ -125,6 +125,10 @@ pub struct CommandLineArgs {
|
|||||||
/// Output logs
|
/// Output logs
|
||||||
#[structopt(short = "v", long = "verbose")]
|
#[structopt(short = "v", long = "verbose")]
|
||||||
verbose: bool,
|
verbose: bool,
|
||||||
|
|
||||||
|
/// Prompt or a key before exiting
|
||||||
|
#[structopt(short = "k", long = "keep")]
|
||||||
|
keep_at_end: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Represents the application configuration
|
/// Represents the application configuration
|
||||||
@@ -207,4 +211,9 @@ impl Config {
|
|||||||
pub fn remote_topgrades(&self) -> &Option<Vec<String>> {
|
pub fn remote_topgrades(&self) -> &Option<Vec<String>> {
|
||||||
&self.config_file.remote_topgrades
|
&self.config_file.remote_topgrades
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Prompt for a key before exiting
|
||||||
|
pub fn keep_at_end(&self) -> bool {
|
||||||
|
self.opt.keep_at_end || env::var("TOPGRADE_KEEP_END").is_ok()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -498,8 +498,8 @@ fn run() -> Result<(), Error> {
|
|||||||
freebsd::audit_packages(&sudo).ok();
|
freebsd::audit_packages(&sudo).ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
if env::var("TOPGRADE_KEEP_END").is_ok() {
|
if config.keep_at_end() {
|
||||||
print_info("\nPress R to reboot, S for shell or any other key to continue");
|
print_info("\n(R)eboot\n(S)hell\n\nPress any other key to continue");
|
||||||
match get_char() {
|
match get_char() {
|
||||||
's' | 'S' => {
|
's' | 'S' => {
|
||||||
run_shell();
|
run_shell();
|
||||||
|
|||||||
@@ -131,5 +131,6 @@ pub fn run_sdkman(base_dirs: &BaseDirs, cleanup: bool, run_type: RunType) -> Res
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn reboot() {
|
pub fn reboot() {
|
||||||
Command::new("sudo").arg("reboot").spawn().ok();
|
print!("Rebooting...");
|
||||||
|
Command::new("sudo").arg("reboot").spawn().unwrap().wait().unwrap();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ impl Terminal {
|
|||||||
fn print_info<P: AsRef<str>>(&mut self, message: P) {
|
fn print_info<P: AsRef<str>>(&mut self, message: P) {
|
||||||
let message = message.as_ref();
|
let message = message.as_ref();
|
||||||
self.term
|
self.term
|
||||||
.write_fmt(format_args!("{}\n", style(message).yellow().bold()))
|
.write_fmt(format_args!("{}\n", style(message).blue().bold()))
|
||||||
.ok();
|
.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user