Skip to content

Commit

Permalink
Switch from structopt to clap in tools/pubsys-setup
Browse files Browse the repository at this point in the history
This removes the structopt dependency in favor of clap.

Signed-off-by: Sean McGinnis <[email protected]>
  • Loading branch information
stmcginnis committed Jun 26, 2023
1 parent acbaba9 commit 9905ffc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 56 deletions.
47 changes: 4 additions & 43 deletions tools/Cargo.lock

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

3 changes: 0 additions & 3 deletions tools/deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ skip = [
]

skip-tree = [
# structopt pulls in an older version of clap
{ name = "structopt", version = "0.3.26" },

# windows-sys is not a direct dependency. mio and schannel
# are using different versions of windows-sys. we skip the
# dependency tree because windows-sys has many sub-crates
Expand Down
2 changes: 1 addition & 1 deletion tools/pubsys-setup/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = "2021"
publish = false

[dependencies]
clap = { version = "4", features = ["derive"] }
hex = "0.4"
log = "0.4"
pubsys-config = { path = "../pubsys-config/", version = "0.1" }
Expand All @@ -15,7 +16,6 @@ sha2 = "0.10"
shell-words = "1"
simplelog = "0.12"
snafu = "0.7"
structopt = { version = "0.3", default-features = false }
tempfile = "3"
toml = "0.5"
url = { version = "2", features = ["serde"] }
19 changes: 10 additions & 9 deletions tools/pubsys-setup/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ the repos you use to update them. Specifically, it can create a new key and rol
existing role.
*/

use clap::Parser;
use log::{debug, info, trace, warn};
use pubsys_config::InfraConfig;
use sha2::{Digest, Sha512};
Expand All @@ -14,33 +15,33 @@ use std::fs;
use std::os::unix::fs::PermissionsExt;
use std::path::PathBuf;
use std::process::{self, Command};
use structopt::StructOpt;
use tempfile::NamedTempFile;
use url::Url;

/// Helps you get started with credentials to make Bottlerocket images and repos.
#[derive(Debug, StructOpt)]
#[derive(Debug, Parser)]
struct Args {
#[structopt(global = true, long, default_value = "INFO")]
#[arg(global = true, long, default_value = "INFO")]
/// How much detail to log; from least to most: ERROR, WARN, INFO, DEBUG, TRACE
log_level: LevelFilter,

#[structopt(long, parse(from_os_str))]
#[arg(long)]
/// Path to Infra.toml
infra_config_path: PathBuf,

#[structopt(long)]
#[arg(long)]
/// Use this named repo infrastructure from Infra.toml
repo: String,

#[structopt(long, parse(from_os_str))]
#[arg(long)]
/// Path to root.json
root_role_path: PathBuf,
#[structopt(long, parse(from_os_str))]

#[arg(long)]
/// If we have to generate a local key, store it here
default_key_path: PathBuf,

#[structopt(long)]
#[arg(long)]
/// Allow setup to continue if we have a root role but no key for it
allow_missing_key: bool,
}
Expand Down Expand Up @@ -71,7 +72,7 @@ macro_rules! tuftool {
/// Main entry point for tuftool setup.
fn run() -> Result<()> {
// Parse and store the args passed to the program
let args = Args::from_args();
let args = Args::parse();

// SimpleLogger will send errors to stderr and anything less to stdout.
SimpleLogger::init(args.log_level, LogConfig::default()).context(error::LoggerSnafu)?;
Expand Down

0 comments on commit 9905ffc

Please sign in to comment.