forked from DGNum/colmena
Fix build and upload-keys
This commit is contained in:
parent
935aa77e53
commit
765a5d2ef3
6 changed files with 41 additions and 53 deletions
42
src/cli.rs
42
src/cli.rs
|
@ -8,7 +8,7 @@ use const_format::{concatcp, formatcp};
|
||||||
use env_logger::fmt::WriteStyle;
|
use env_logger::fmt::WriteStyle;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
command,
|
command::{self, apply::DeployOpts},
|
||||||
error::ColmenaResult,
|
error::ColmenaResult,
|
||||||
nix::{Hive, HivePath},
|
nix::{Hive, HivePath},
|
||||||
};
|
};
|
||||||
|
@ -160,9 +160,27 @@ enum Command {
|
||||||
Apply(command::apply::Opts),
|
Apply(command::apply::Opts),
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
ApplyLocal(command::apply_local::Opts),
|
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),
|
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),
|
Exec(command::exec::Opts),
|
||||||
Repl(command::repl::Opts),
|
Repl(command::repl::Opts),
|
||||||
NixInfo(command::nix_info::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::NixInfo(args) => r(command::nix_info::run(args)).await,
|
||||||
Command::Repl(args) => r(command::repl::run(hive, args)).await,
|
Command::Repl(args) => r(command::repl::run(hive, args)).await,
|
||||||
Command::TestProgress => r(command::test_progress::run()).await,
|
Command::TestProgress => r(command::test_progress::run()).await,
|
||||||
Command::Build(_args) => todo!("This is an alias for `colmena apply build`"),
|
Command::Build { deploy } => {
|
||||||
Command::UploadKeys(_opts) => todo!("This is an alias for `colmena apply upload-keys`"),
|
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()),
|
Command::GenCompletions { shell } => print_completions(shell, &mut Opts::command()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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"))
|
default_value_if("reboot", ArgPredicate::IsPresent, Some("boot"))
|
||||||
)]
|
)]
|
||||||
goal: Goal,
|
pub goal: Goal,
|
||||||
#[command(flatten)]
|
#[command(flatten)]
|
||||||
deploy: DeployOpts,
|
pub deploy: DeployOpts,
|
||||||
#[command(flatten)]
|
#[command(flatten)]
|
||||||
node_filter: NodeFilterOpts,
|
pub node_filter: NodeFilterOpts,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn run(hive: Hive, opts: Opts) -> Result<(), ColmenaError> {
|
pub async fn run(hive: Hive, opts: Opts) -> Result<(), ColmenaError> {
|
||||||
|
|
|
@ -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,
|
|
||||||
}
|
|
|
@ -1,10 +1,8 @@
|
||||||
pub mod apply;
|
pub mod apply;
|
||||||
pub mod build;
|
|
||||||
pub mod eval;
|
pub mod eval;
|
||||||
pub mod exec;
|
pub mod exec;
|
||||||
pub mod nix_info;
|
pub mod nix_info;
|
||||||
pub mod repl;
|
pub mod repl;
|
||||||
pub mod upload_keys;
|
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
pub mod apply_local;
|
pub mod apply_local;
|
||||||
|
|
|
@ -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,
|
|
||||||
}
|
|
|
@ -10,7 +10,7 @@ use glob::Pattern as GlobPattern;
|
||||||
|
|
||||||
use super::{ColmenaError, ColmenaResult, NodeConfig, NodeName};
|
use super::{ColmenaError, ColmenaResult, NodeConfig, NodeName};
|
||||||
|
|
||||||
#[derive(Debug, Args)]
|
#[derive(Debug, Default, Args)]
|
||||||
pub struct NodeFilterOpts {
|
pub struct NodeFilterOpts {
|
||||||
#[arg(
|
#[arg(
|
||||||
long,
|
long,
|
||||||
|
|
Loading…
Reference in a new issue