Skip to content

Commit

Permalink
cli: Migrate to clap Derive
Browse files Browse the repository at this point in the history
Signed-off-by: Evan Maddock <[email protected]>
  • Loading branch information
EbonJaeger committed Mar 7, 2024
1 parent 3047d89 commit ab3ff3c
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 10 deletions.
19 changes: 19 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2021"
[dependencies]
async-process = "1.8.1"
bincode = "1.3.3"
clap = "4.4.7"
clap = { version = "4.4.7", features = ["derive"] }
dag = { git = "https://github.com/serpent-os/moss-rs.git", version = "0.1.0" }
futures = "0.3.29"
regex = "1.10.2"
Expand Down
29 changes: 20 additions & 9 deletions src/bin/usysconf/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,32 @@
//
// SPDX-License-Identifier: MPL-2.0

use clap::Command;
use clap::{Parser, Subcommand};
use thiserror::Error;

/// Generate the CLI command structure
fn command() -> Command {
Command::new("usysconf")
.about("Univeral system configuration")
.long_about("System configuration agent for modern Linux distributions to handle a variety of installation and removal triggers")
.arg_required_else_help(true)
#[derive(Parser)]
#[command(author, version = None)]
#[command(about = "Universal system configuration")]
#[command(long_about = "System configuration agent for modern linux distributions to handle a variety of installation and removal triggers")]
#[command(arg_required_else_help = true)]
struct Cli {
#[command(subcommand)]
command: Option<Commands>,
}

#[derive(Subcommand)]
enum Commands {}

/// Process CLI arguments for usysconf binary
pub fn process() -> Result<(), Error> {
let _ = command().get_matches();
Err(Error::NotImplemented)
let cli = Cli::parse();

match &cli.command {
Some(_) => return Err(Error::NotImplemented),
None => {}
};

Ok(())
}

#[derive(Debug, Error)]
Expand Down

0 comments on commit ab3ff3c

Please sign in to comment.