use clap::Parser;
pub fn main() {
let args = Args::parse();
if args.update {
return update();
}
if args.update_dev {
return update_dev();
}
if args.uninstall {
return uninstall();
}
help();
}
#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
struct Args {
#[arg(short, long, default_value_t = false)]
update: bool,
#[arg(short = 'D', long, default_value_t = false)]
update_dev: bool,
#[arg(short = 'x', long, default_value_t = false)]
uninstall: bool,
#[arg(short, long, default_value_t = String::from(".microCI.yml"))]
input: String,
}
pub fn update() {
let cmds = r#"
echo "🚀 Updating to the latest stable release..."
sudo curl -fsSL \
github.com/geraldolsribeiro/microci/releases/latest/download/microCI \
-o /usr/bin/microCI
sudo chmod 755 /usr/bin/microCI
microCI --version
"#;
println!("{}", cmds)
}
pub fn update_dev() {
let cmds = r#"
echo "🚧 Updating to the development stream..."
sudo curl -fsSL \
github.com/geraldolsribeiro/microci/releases/download/latest/microCI \
-o /usr/bin/microCI
sudo chmod 755 /usr/bin/microCI
microCI --version
"#;
println!("{}", cmds)
}
pub fn uninstall() {
let cmds = r#"
echo "🔥 Removing microCI..."
sudo rm -f /usr/bin/microCI
"#;
println!("{}", cmds)
}
fn help() {
println!(
"Options:
-h,--help Print this help
-V,--version Print the microCI version
-T,--test-config Configuration test
-A,--activity-diagram Generate activity diagram
-a,--append-log Append log
-O,--only name Execute only a single step
-l,--list List steps
-N,--number N Execute the Nth step
-x,--hash hh Execute the hh step
-U,--update-db Update observability database
-u,--update Update microCI to stable stream
-D,--update-dev Update microCI to development stream
-x,--uninstall Uninstall
-i,--input file.yml Load the configuration from file.yml
-H,--home alt_home_dir Alternative home directory
-n,--config gitlab_ci Create a .gitlab-ci.yml example config
-n,--new skip Create a placeholder step
-n,--new bash Create a command line step
-n,--new docmd Create a documentation step
-n,--new mkdocs_material Create a documentation step
-n,--new doxygen Create a documentation step
-n,--new pandoc Create a document conversion step
-n,--new git_publish Create a publish step
-n,--new git_deploy Create a production deploy step
-n,--new plantuml Create a diagram generation step
-n,--new pikchr Create a diagram generation step
-n,--new clang-format Create a code format step
-n,--new vhdl-format Create a code format step
-n,--new beamer Create a PDF presentation step
-n,--new fetch Create a download external artfact step
-n,--new minio Create a upload/download internal artifact step
-n,--new cppcheck Create a C++ SAST step
-n,--new clang-tidy Create a C++ SAST step
-n,--new flawfinder Create a C++ SAST step
-n,--new docker_build Create a local docker build step
-n,--new template Create a template step
"
)
}
pub fn add(left: u64, right: u64) -> u64 {
left + right
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}