Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: replace structopt/paw with clap #419

Merged
merged 1 commit into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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