Code optimise
parent
9f8ba7b3d7
commit
fffa888658
@ -1,71 +1,71 @@
|
|||||||
use clap::{ArgAction, Parser, Subcommand};
|
use clap::{ArgAction, Parser, Subcommand};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Parser)]
|
#[derive(Debug, Clone, Parser)]
|
||||||
#[clap(name="Malachite", version=env!("CARGO_PKG_VERSION"), about=env!("CARGO_PKG_DESCRIPTION"))]
|
#[clap(name = "Malachite", version = env ! ("CARGO_PKG_VERSION"), about = env ! ("CARGO_PKG_DESCRIPTION"))]
|
||||||
pub struct Args {
|
pub struct Args {
|
||||||
#[clap(subcommand)]
|
#[clap(subcommand)]
|
||||||
pub subcommand: Option<Operation>,
|
pub subcommand: Option<Operation>,
|
||||||
|
|
||||||
/// Sets the level of verbosity
|
/// Sets the level of verbosity
|
||||||
#[clap(long, short, global(true), action=ArgAction::Count)]
|
#[clap(long, short, global(true), action = ArgAction::Count)]
|
||||||
pub verbose: u8,
|
pub verbose: u8,
|
||||||
|
|
||||||
/// Complete operations without prompting user
|
/// Complete operations without prompting user
|
||||||
#[clap(long="noconfirm", global(true), action=ArgAction::SetTrue)]
|
#[clap(long = "noconfirm", global(true), action = ArgAction::SetTrue)]
|
||||||
pub no_confirm: bool,
|
pub no_confirm: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Subcommand)]
|
#[derive(Debug, Clone, Subcommand)]
|
||||||
pub enum Operation {
|
pub enum Operation {
|
||||||
/// Builds the given packages
|
/// Builds the given packages
|
||||||
#[clap(name="build", aliases=&["b"])]
|
#[clap(name = "build", aliases = & ["b"])]
|
||||||
Build {
|
Build {
|
||||||
/// The packages to operate on
|
/// The packages to operate on
|
||||||
#[clap(name="package(s)", action=ArgAction::Append, index=1)]
|
#[clap(name = "package(s)", action = ArgAction::Append, index = 1)]
|
||||||
packages: Vec<String>,
|
packages: Vec<String>,
|
||||||
|
|
||||||
/// Builds all packages in mlc.toml (except if -x is specified)
|
/// Builds all packages in mlc.toml (except if -x is specified)
|
||||||
#[clap(long="all", takes_value=false, action=ArgAction::SetTrue, conflicts_with="package(s)")]
|
#[clap(long = "all", takes_value = false, action = ArgAction::SetTrue, conflicts_with = "package(s)")]
|
||||||
all: bool,
|
all: bool,
|
||||||
|
|
||||||
/// Excludes packages from given operation
|
/// Excludes packages from given operation
|
||||||
#[clap(short='x', long="exclude", action=ArgAction::Append, takes_value=true)]
|
#[clap(short = 'x', long = "exclude", action = ArgAction::Append, takes_value = true)]
|
||||||
exclude: Vec<String>,
|
exclude: Vec<String>,
|
||||||
|
|
||||||
/// Does not regenerate repository after building given package(s)
|
/// Does not regenerate repository after building given package(s)
|
||||||
#[clap(short='n', long="no-regen", action=ArgAction::SetTrue)]
|
#[clap(short = 'n', long = "no-regen", action = ArgAction::SetTrue)]
|
||||||
no_regen: bool,
|
no_regen: bool,
|
||||||
},
|
},
|
||||||
|
|
||||||
/// Generates repository from built packages
|
/// Generates repository from built packages
|
||||||
#[clap(name="repo-gen", aliases=&["r"])]
|
#[clap(name = "repo-gen", aliases = & ["r"])]
|
||||||
RepoGen,
|
RepoGen,
|
||||||
|
|
||||||
/// Prunes duplicate packages from the repository
|
/// Prunes duplicate packages from the repository
|
||||||
#[clap(name="prune", aliases=&["p"])]
|
#[clap(name = "prune", aliases = & ["p"])]
|
||||||
Prune,
|
Prune,
|
||||||
|
|
||||||
/// Clones all git repositories from mlc.toml branching from current directory
|
/// Clones all git repositories from mlc.toml branching from current directory
|
||||||
#[clap(name="init", aliases=&["i"])]
|
#[clap(name = "init", aliases = & ["i"])]
|
||||||
Init,
|
Init,
|
||||||
|
|
||||||
/// Pulls in git repositories from mlc.toml branching from current directory
|
/// Pulls in git repositories from mlc.toml branching from current directory
|
||||||
#[clap(name="pull", aliases=&["u"])]
|
#[clap(name = "pull", aliases = & ["u"])]
|
||||||
Pull {
|
Pull {
|
||||||
/// The packages to operate on
|
/// The packages to operate on
|
||||||
#[clap(name="package(s)", help="The packages to operate on", action=ArgAction::Append, index=1)]
|
#[clap(name = "package(s)", help = "The packages to operate on", action = ArgAction::Append, index = 1)]
|
||||||
packages: Vec<String>,
|
packages: Vec<String>,
|
||||||
|
|
||||||
/// Pulls from all git repositories from mlc.toml branching from current directory
|
/// Pulls from all git repositories from mlc.toml branching from current directory
|
||||||
#[clap(long="all", action=ArgAction::SetTrue, conflicts_with="package(s)")]
|
#[clap(long = "all", action = ArgAction::SetTrue, conflicts_with = "package(s)")]
|
||||||
all: bool,
|
all: bool,
|
||||||
|
|
||||||
/// Excludes packages from given operation
|
/// Excludes packages from given operation
|
||||||
#[clap(short='x', long="exclude", action=ArgAction::Append, takes_value=true)]
|
#[clap(short = 'x', long = "exclude", action = ArgAction::Append, takes_value = true)]
|
||||||
exclude: Vec<String>,
|
exclude: Vec<String>,
|
||||||
},
|
},
|
||||||
|
|
||||||
/// Create and/or open local config file
|
/// Create and/or open local config file
|
||||||
#[clap(name="config", aliases=&["c"])]
|
#[clap(name = "config", aliases = & ["c"])]
|
||||||
Config,
|
Config,
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
mod build;
|
|
||||||
mod config;
|
|
||||||
mod init;
|
|
||||||
mod prune;
|
|
||||||
mod pull;
|
|
||||||
|
|
||||||
pub use build::*;
|
pub use build::*;
|
||||||
pub use config::*;
|
pub use config::*;
|
||||||
pub use init::*;
|
pub use init::*;
|
||||||
pub use prune::*;
|
pub use prune::*;
|
||||||
pub use pull::*;
|
pub use pull::*;
|
||||||
|
|
||||||
|
mod build;
|
||||||
|
mod config;
|
||||||
|
mod init;
|
||||||
|
mod prune;
|
||||||
|
mod pull;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
mod config;
|
|
||||||
mod package;
|
|
||||||
mod repo;
|
|
||||||
|
|
||||||
pub use config::*;
|
pub use config::*;
|
||||||
pub use package::*;
|
pub use package::*;
|
||||||
pub use repo::*;
|
pub use repo::*;
|
||||||
|
|
||||||
|
mod config;
|
||||||
|
mod package;
|
||||||
|
mod repo;
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
mod read;
|
|
||||||
|
|
||||||
pub use read::*;
|
pub use read::*;
|
||||||
|
|
||||||
|
mod read;
|
||||||
|
Loading…
Reference in New Issue