2020-12-16 05:21:26 +01:00
|
|
|
use clap::{App, AppSettings};
|
|
|
|
|
|
|
|
mod nix;
|
|
|
|
mod command;
|
|
|
|
mod progress;
|
|
|
|
mod deployment;
|
|
|
|
mod util;
|
|
|
|
|
2020-12-18 10:27:44 +01:00
|
|
|
macro_rules! command {
|
2020-12-20 00:07:29 +01:00
|
|
|
($module:ident, $matches:ident) => {
|
|
|
|
if let Some(sub_matches) = $matches.subcommand_matches(stringify!($module)) {
|
|
|
|
command::$module::run(&$matches, &sub_matches).await;
|
2020-12-18 10:27:44 +01:00
|
|
|
return;
|
|
|
|
}
|
2020-12-20 00:07:29 +01:00
|
|
|
};
|
|
|
|
($name:expr, $module:ident, $matches:ident) => {
|
|
|
|
if let Some(sub_matches) = $matches.subcommand_matches($name) {
|
|
|
|
command::$module::run(&$matches, &sub_matches).await;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
};
|
2020-12-18 10:27:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
macro_rules! bind_command {
|
2020-12-20 00:07:29 +01:00
|
|
|
($module:ident, $app:ident) => {
|
|
|
|
$app = $app.subcommand(command::$module::subcommand());
|
|
|
|
};
|
2020-12-18 10:27:44 +01:00
|
|
|
}
|
|
|
|
|
2020-12-16 05:21:26 +01:00
|
|
|
#[tokio::main(flavor = "multi_thread")]
|
2020-12-18 10:27:44 +01:00
|
|
|
async fn main() {
|
|
|
|
let mut app = App::new("Colmena")
|
2020-12-16 05:21:26 +01:00
|
|
|
.version("0.1.0")
|
|
|
|
.author("Zhaofeng Li <hello@zhaofeng.li>")
|
|
|
|
.about("NixOS deployment tool")
|
|
|
|
.global_setting(AppSettings::ColoredHelp)
|
2020-12-18 10:27:44 +01:00
|
|
|
.setting(AppSettings::ArgRequiredElseHelp);
|
2020-12-16 05:21:26 +01:00
|
|
|
|
2020-12-18 10:27:44 +01:00
|
|
|
bind_command!(apply, app);
|
2020-12-20 00:07:29 +01:00
|
|
|
bind_command!(apply_local, app);
|
2020-12-18 10:27:44 +01:00
|
|
|
bind_command!(build, app);
|
|
|
|
bind_command!(introspect, app);
|
|
|
|
|
|
|
|
let matches = app.get_matches();
|
2020-12-16 05:21:26 +01:00
|
|
|
|
2020-12-18 10:27:44 +01:00
|
|
|
command!(apply, matches);
|
2020-12-20 00:07:29 +01:00
|
|
|
command!("apply-local", apply_local, matches);
|
2020-12-18 10:27:44 +01:00
|
|
|
command!(build, matches);
|
|
|
|
command!(introspect, matches);
|
2020-12-16 05:21:26 +01:00
|
|
|
}
|