Set up initial structure for the nix builder.
This commit is contained in:
1
src/cli/mod.rs
Normal file
1
src/cli/mod.rs
Normal file
@@ -0,0 +1 @@
|
||||
pub(crate) mod parameters;
|
||||
52
src/cli/parameters.rs
Normal file
52
src/cli/parameters.rs
Normal file
@@ -0,0 +1,52 @@
|
||||
use clap::Args;
|
||||
use clap::Parser;
|
||||
use clap::Subcommand;
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(name = "nix_builder")]
|
||||
#[command(version = env!("CARGO_PKG_VERSION"))]
|
||||
#[command(about = "Build nix packages.", long_about = None)]
|
||||
#[command(propagate_version = true)]
|
||||
pub(crate) struct Cli {
|
||||
#[command(subcommand)]
|
||||
pub(crate) command: Commands,
|
||||
}
|
||||
|
||||
#[derive(Subcommand, Debug)]
|
||||
pub(crate) enum Commands {
|
||||
/// Run a single build.
|
||||
Build(BuildArgs),
|
||||
|
||||
/// Launch a daemon to run builds.
|
||||
Daemon(DaemonArgs),
|
||||
}
|
||||
|
||||
#[derive(Args, Debug)]
|
||||
pub(crate) struct BuildArgs {
|
||||
/// Path to the nix_builder config file.
|
||||
#[arg(short, long)]
|
||||
pub(crate) config: PathBuf,
|
||||
|
||||
/// The target to build.
|
||||
#[arg(short, long)]
|
||||
pub(crate) target: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Args, Debug)]
|
||||
pub(crate) struct DaemonArgs {
|
||||
/// Path to the nix_builder config file.
|
||||
#[arg(short, long)]
|
||||
pub(crate) path: PathBuf,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn verify_cli() {
|
||||
use clap::CommandFactory;
|
||||
Cli::command().debug_assert()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user