diff --git a/leo/cli.rs b/leo/cli.rs index 42f9b4683b..acad5a2f58 100644 --- a/leo/cli.rs +++ b/leo/cli.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::{cli_types::*, errors::CLIError, logger}; +use crate::{cli_types::*, errors::CLIError, logger, updater::Updater}; use clap::{App, AppSettings, Arg, ArgMatches, SubCommand}; @@ -90,6 +90,10 @@ pub trait CLI { false => logger::init_logger("leo", 1), } + if arguments.subcommand().0 != "update" { + Updater::print_cli(); + } + let options = Self::parse(arguments)?; let _output = Self::output(options)?; Ok(()) diff --git a/leo/config.rs b/leo/config.rs index 48a041eba2..ff15ff4725 100644 --- a/leo/config.rs +++ b/leo/config.rs @@ -56,7 +56,7 @@ pub struct Config { impl Default for Config { fn default() -> Self { - Self { auto_update: true } + Self { auto_update: false } } } diff --git a/leo/main.rs b/leo/main.rs index 0ca48d96a5..7c8c124904 100644 --- a/leo/main.rs +++ b/leo/main.rs @@ -14,13 +14,13 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use leo_lang::{cli::*, commands::*, config::Config, errors::CLIError}; +use leo_lang::{cli::*, commands::*, errors::CLIError, logger, updater::Updater}; use clap::{App, AppSettings, Arg}; #[cfg_attr(tarpaulin, skip)] fn main() -> Result<(), CLIError> { - let arguments = App::new("leo") + let app = App::new("leo") .version(include_str!("./leo-version")) .about("Leo compiler and package manager") .author("The Aleo Team ") @@ -28,7 +28,6 @@ fn main() -> Result<(), CLIError> { AppSettings::ColoredHelp, AppSettings::DisableHelpSubcommand, AppSettings::DisableVersion, - AppSettings::SubcommandRequiredElseHelp, ]) .args(&[Arg::with_name("debug") .short("d") @@ -53,18 +52,10 @@ fn main() -> Result<(), CLIError> { LintCommand::new().display_order(14), UpdateCommand::new().display_order(15), ]) - .set_term_width(0) - .get_matches(); + .set_term_width(0); - let config = Config::read_config()?; - - if config.auto_update && arguments.subcommand().0 != "update" { - if let Ok(status) = UpdateCommand::update_to_latest_release(false) { - if status.updated() { - tracing::info!("Leo has successfully updated to version: {}", status.version()); - } - } - } + let mut help = app.clone(); + let arguments = app.get_matches(); match arguments.subcommand() { ("new", Some(arguments)) => NewCommand::process(arguments), @@ -83,6 +74,17 @@ fn main() -> Result<(), CLIError> { ("clean", Some(arguments)) => CleanCommand::process(arguments), ("lint", Some(arguments)) => LintCommand::process(arguments), ("update", Some(arguments)) => UpdateCommand::process(arguments), - _ => unreachable!(), + _ => { + // Set logging environment + match arguments.is_present("debug") { + true => logger::init_logger("leo", 2), + false => logger::init_logger("leo", 1), + } + + Updater::print_cli(); + + help.print_help()?; + Ok(()) + } } }