Skip to content

Commit 2cc91c6

Browse files
committed
cli: Migrate to clap Derive
Signed-off-by: Evan Maddock <[email protected]>
1 parent 538cca9 commit 2cc91c6

File tree

3 files changed

+40
-10
lines changed

3 files changed

+40
-10
lines changed

Cargo.lock

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ edition = "2021"
88
[dependencies]
99
async-process = "1.8.1"
1010
bincode = "1.3.3"
11-
clap = "4.4.7"
11+
clap = { version = "4.4.7", features = ["derive"] }
1212
dag = { git = "https://github.com/serpent-os/moss-rs.git", version = "0.1.0" }
1313
futures = "0.3.29"
1414
serde = { version = "1.0.190", features = ["derive"] }

src/bin/usysconf/cli/mod.rs

+20-9
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,32 @@
22
//
33
// SPDX-License-Identifier: MPL-2.0
44

5-
use clap::Command;
5+
use clap::{Parser, Subcommand};
66
use thiserror::Error;
77

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

18+
#[derive(Subcommand)]
19+
enum Commands {}
20+
1621
/// Process CLI arguments for usysconf binary
1722
pub fn process() -> Result<(), Error> {
18-
let _ = command().get_matches();
19-
Err(Error::NotImplemented)
23+
let cli = Cli::parse();
24+
25+
match &cli.command {
26+
Some(_) => return Err(Error::NotImplemented),
27+
None => {}
28+
};
29+
30+
Ok(())
2031
}
2132

2233
#[derive(Debug, Error)]

0 commit comments

Comments
 (0)