Fix build and upload-keys

This commit is contained in:
i1i1 2023-08-10 18:06:08 +03:00 committed by Zhaofeng Li
parent 935aa77e53
commit 765a5d2ef3
6 changed files with 41 additions and 53 deletions

View file

@ -8,7 +8,7 @@ use const_format::{concatcp, formatcp};
use env_logger::fmt::WriteStyle;
use crate::{
command,
command::{self, apply::DeployOpts},
error::ColmenaResult,
nix::{Hive, HivePath},
};
@ -160,9 +160,27 @@ enum Command {
Apply(command::apply::Opts),
#[cfg(target_os = "linux")]
ApplyLocal(command::apply_local::Opts),
Build(command::build::Opts),
#[command(
about = "Build configurations but not push to remote machines",
long_about = r#"Build configurations but not push to remote machines
This subcommand behaves as if you invoked `apply` with the `build` goal."#
)]
Build {
#[command(flatten)]
deploy: DeployOpts,
},
Eval(command::eval::Opts),
UploadKeys(command::upload_keys::Opts),
#[command(
about = "Upload keys to remote hosts",
long_about = r#"Upload keys to remote hosts
This subcommand behaves as if you invoked `apply` with the pseudo `keys` goal."#
)]
UploadKeys {
#[command(flatten)]
deploy: DeployOpts,
},
Exec(command::exec::Opts),
Repl(command::repl::Opts),
NixInfo(command::nix_info::Opts),
@ -261,8 +279,22 @@ pub async fn run() {
Command::NixInfo(args) => r(command::nix_info::run(args)).await,
Command::Repl(args) => r(command::repl::run(hive, args)).await,
Command::TestProgress => r(command::test_progress::run()).await,
Command::Build(_args) => todo!("This is an alias for `colmena apply build`"),
Command::UploadKeys(_opts) => todo!("This is an alias for `colmena apply upload-keys`"),
Command::Build { deploy } => {
let args = command::apply::Opts {
deploy,
goal: crate::nix::Goal::Build,
node_filter: Default::default(),
};
r(command::apply::run(hive, args)).await
},
Command::UploadKeys { deploy } => {
let args = command::apply::Opts {
deploy,
goal: crate::nix::Goal::UploadKeys,
node_filter: Default::default(),
};
r(command::apply::run(hive, args)).await
},
Command::GenCompletions { shell } => print_completions(shell, &mut Opts::command()),
}
}

View file

@ -132,11 +132,11 @@ Same as the targets for switch-to-configuration, with the following extra pseudo
"#,
default_value_if("reboot", ArgPredicate::IsPresent, Some("boot"))
)]
goal: Goal,
pub goal: Goal,
#[command(flatten)]
deploy: DeployOpts,
pub deploy: DeployOpts,
#[command(flatten)]
node_filter: NodeFilterOpts,
pub node_filter: NodeFilterOpts,
}
pub async fn run(hive: Hive, opts: Opts) -> Result<(), ColmenaError> {

View file

@ -1,21 +0,0 @@
use clap::Args;
use crate::nix::Goal;
pub use super::apply::run;
use super::apply::DeployOpts;
#[derive(Debug, Args)]
#[command(
name = "build",
about = "Build configurations but not push to remote machines",
long_about = r#"Build configurations but not push to remote machines
This subcommand behaves as if you invoked `apply` with the `build` goal."#
)]
pub struct Opts {
#[command(flatten)]
deploy: DeployOpts,
#[arg(hide = true, default_value_t = Goal::Build)]
goal: Goal,
}

View file

@ -1,10 +1,8 @@
pub mod apply;
pub mod build;
pub mod eval;
pub mod exec;
pub mod nix_info;
pub mod repl;
pub mod upload_keys;
#[cfg(target_os = "linux")]
pub mod apply_local;

View file

@ -1,21 +0,0 @@
use clap::Args;
use crate::nix::Goal;
pub use super::apply::run;
use super::apply::DeployOpts;
#[derive(Debug, Args)]
#[command(
name = "upload-keys",
about = "Upload keys to remote hosts",
long_about = r#"Upload keys to remote hosts
This subcommand behaves as if you invoked `apply` with the pseudo `keys` goal."#
)]
pub struct Opts {
#[command(flatten)]
deploy: DeployOpts,
#[arg(hide = true, default_value_t = Goal::Build)]
goal: Goal,
}

View file

@ -10,7 +10,7 @@ use glob::Pattern as GlobPattern;
use super::{ColmenaError, ColmenaResult, NodeConfig, NodeName};
#[derive(Debug, Args)]
#[derive(Debug, Default, Args)]
pub struct NodeFilterOpts {
#[arg(
long,