Skip to content

Commit

Permalink
refactor: replace structopt/paw with clap (#419)
Browse files Browse the repository at this point in the history
  • Loading branch information
shawn111 committed May 1, 2024
1 parent 1d75877 commit c095ed8
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 167 deletions.
154 changes: 20 additions & 134 deletions Cargo.lock

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

3 changes: 1 addition & 2 deletions app/Cargo.toml
Expand Up @@ -8,14 +8,13 @@ description = "A tool to simplify reprovisioning a fresh OS. Installs packages a

[dependencies]
anyhow = "1.0"
clap = { version = "4.5.4", features = ["derive"] }
colored = "2.1"
comfy-table = "7"
comtrya-lib = { path = "../lib", version = "0.8.8" }
paw = "1.0"
petgraph = "0.6"
rhai = { version = "1.17", features = ["serde"] }
strip-ansi-escapes = "0.2"
structopt = { version = "0.3", features = ["paw"] }
tracing = "0.1"
tracing-journald = "0.3.0"
tracing-subscriber = "0.3"
Expand Down
11 changes: 6 additions & 5 deletions app/src/commands/apply.rs
@@ -1,25 +1,26 @@
use super::ComtryaCommand;
use crate::Runtime;
use clap::Parser;
use comtrya_lib::contexts::to_rhai;
use comtrya_lib::manifests::{load, Manifest};
use core::panic;
use petgraph::{visit::DfsPostOrder, Graph};
use rhai::Engine;
use std::{collections::HashMap, ops::Deref};
use structopt::StructOpt;
use tracing::{debug, error, info, instrument, span, trace, warn};

#[derive(Clone, Debug, StructOpt)]
#[derive(Parser, Debug)]
pub(crate) struct Apply {
/// Run a subset of your manifests, comma separated list
#[structopt(short = "m", long, use_delimiter = true)]
#[arg(short, long, value_delimiter = ',')]
manifests: Vec<String>,

/// Performs a dry-run without changing the system
#[structopt(long)]
#[arg(long)]
dry_run: bool,

#[structopt(short = "l", long = "label")]
/// Define label selector
#[arg(short, long)]
pub label: Option<String>,
}

Expand Down
8 changes: 5 additions & 3 deletions app/src/commands/contexts.rs
Expand Up @@ -2,12 +2,14 @@ use super::ComtryaCommand;
use crate::Runtime;
use colored::Colorize;
use comfy_table::{presets::NOTHING, Attribute, Cell, ContentArrangement, Table};
use structopt::StructOpt;

#[derive(Clone, Debug, StructOpt)]
use clap::Parser;

#[derive(Parser, Debug)]
#[command()]
pub(crate) struct Contexts {
/// Show the values of the contexts
#[structopt(long)]
#[arg(long)]
show_values: bool,
}

Expand Down
6 changes: 4 additions & 2 deletions app/src/commands/version.rs
@@ -1,8 +1,10 @@
use super::ComtryaCommand;
use crate::Runtime;
use structopt::StructOpt;

#[derive(Clone, Debug, StructOpt)]
use clap::Parser;

#[derive(Parser, Debug)]
#[command()]
pub(crate) struct Version {}

impl ComtryaCommand for Version {
Expand Down
4 changes: 2 additions & 2 deletions app/src/config/mod.rs
Expand Up @@ -5,9 +5,9 @@ pub use comtrya_lib::config::Config;
use tracing::instrument;

#[instrument(name = "load_config", level = "info")]
pub(crate) fn load_config(args: GlobalArgs) -> Result<Config> {
pub(crate) fn load_config(args: &GlobalArgs) -> Result<Config> {
match lib_config() {
Ok(config) => match args.manifest_directory {
Ok(config) => match args.manifest_directory.clone() {
Some(manifest_path) => Ok(Config {
manifest_paths: vec![manifest_path],
..config
Expand Down

0 comments on commit c095ed8

Please sign in to comment.