Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add detailed version information #1202

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 146 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 32 additions & 3 deletions packages_rs/nextclade-cli/src/cli/nextalign_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ use itertools::Itertools;
use nextclade::align::params::AlignPairwiseParamsOptional;
use nextclade::io::fs::add_extension;
use nextclade::make_error;
use nextclade::utils::build_info::get_build_info;
use nextclade::utils::global_init::setup_logger;
use std::fmt::Debug;
use std::io;
use std::path::PathBuf;
use std::process::exit;
use strum::IntoEnumIterator;
use strum_macros::EnumIter;

Expand All @@ -31,11 +33,23 @@ use strum_macros::EnumIter;
/// Please read short help with `nextalign -h` and extended help with `nextalign --help`. Each subcommand has its own help, for example: `nextclade run --help`.
pub struct NextalignArgs {
#[clap(subcommand)]
pub command: NextalignCommands,
pub command: Option<NextalignCommands>,

/// Make output more quiet or more verbose
#[clap(flatten, next_help_heading = " Verbosity")]
pub verbosity: Verbosity<WarnLevel>,

/// Detailed version information
#[clap(long, short = 'W', global = true)]
pub version_detailed: bool,

/// Full version information
#[clap(long, short = 'X', global = true)]
pub version_full: bool,

/// Full version information in JSON format
#[clap(long, short = 'Y', global = true)]
pub version_json: bool,
}

#[derive(Subcommand, Debug)]
Expand Down Expand Up @@ -446,19 +460,34 @@ pub fn nextalign_check_removed_args(run_args: &mut NextalignRunArgs) -> Result<(
Ok(())
}

#[allow(clippy::exit)]
pub fn nextalign_handle_cli_args() -> Result<(), Report> {
let args = NextalignArgs::parse();

setup_logger(args.verbosity.get_filter_level());

if args.version_detailed {
println!("{}", get_build_info().detailed()?);
exit(0);
} else if args.version_full {
println!("{}", get_build_info().full()?);
exit(0);
} else if args.version_json {
println!("{}", get_build_info().json()?);
exit(0);
}

match args.command {
NextalignCommands::Completions { shell } => {
Some(NextalignCommands::Completions { shell }) => {
generate_completions(&shell).wrap_err_with(|| format!("When generating completions for shell '{shell}'"))
}
NextalignCommands::Run(mut run_args) => {
Some(NextalignCommands::Run(mut run_args)) => {
nextalign_check_removed_args(&mut run_args)?;
nextalign_get_output_filenames(&mut run_args).wrap_err("When deducing output filenames")?;
nextalign_run(*run_args)
}
_ => {
make_error!("Nextalign requires a command as the first argument. Please type `nextalign --help` for more info.")
}
}
}
Loading