forked from DGNum/colmena
Refactoring and other stuff
This commit is contained in:
parent
65cb370bef
commit
d0ed138ef0
14 changed files with 595 additions and 392 deletions
41
src/main.rs
41
src/main.rs
|
@ -6,26 +6,37 @@ mod progress;
|
|||
mod deployment;
|
||||
mod util;
|
||||
|
||||
macro_rules! command {
|
||||
($name:ident, $matches:ident) => {
|
||||
if let Some(sub_matches) = $matches.subcommand_matches(stringify!($name)) {
|
||||
command::$name::run(&$matches, &sub_matches).await;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! bind_command {
|
||||
($name:ident, $app:ident) => {
|
||||
$app = $app.subcommand(command::$name::subcommand());
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::main(flavor = "multi_thread")]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>>{
|
||||
let matches = App::new("Colmena")
|
||||
async fn main() {
|
||||
let mut app = App::new("Colmena")
|
||||
.version("0.1.0")
|
||||
.author("Zhaofeng Li <hello@zhaofeng.li>")
|
||||
.about("NixOS deployment tool")
|
||||
.global_setting(AppSettings::ColoredHelp)
|
||||
.setting(AppSettings::ArgRequiredElseHelp)
|
||||
.subcommand(command::apply::subcommand())
|
||||
.subcommand(command::build::subcommand())
|
||||
.get_matches();
|
||||
.setting(AppSettings::ArgRequiredElseHelp);
|
||||
|
||||
if let Some(sub_matches) = matches.subcommand_matches("build") {
|
||||
command::build::run(&matches, &sub_matches).await;
|
||||
return Ok(());
|
||||
}
|
||||
if let Some(sub_matches) = matches.subcommand_matches("apply") {
|
||||
command::apply::run(&matches, &sub_matches).await;
|
||||
return Ok(());
|
||||
}
|
||||
bind_command!(apply, app);
|
||||
bind_command!(build, app);
|
||||
bind_command!(introspect, app);
|
||||
|
||||
Ok(())
|
||||
let matches = app.get_matches();
|
||||
|
||||
command!(apply, matches);
|
||||
command!(build, matches);
|
||||
command!(introspect, matches);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue