Skip to content

Commit

Permalink
refactor(crypto): Rename sign command to crypto
Browse files Browse the repository at this point in the history
  • Loading branch information
passcod committed Feb 11, 2024
1 parent 3433105 commit 6aa4835
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 46 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"rust-analyzer.showUnlinkedFileNotification": false
}
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ build-data = "0.1.5"
windows_exe_info = { version = "0.4.1", features = ["manifest"] }

[features]
default = ["dyndns", "sign", "tamanu", "upload"]
default = ["dyndns", "crypto", "tamanu", "upload"]

## Common dep groups (not meant to be used directly)
aws = ["dep:aws-config", "dep:aws-credential-types", "dep:aws-sdk-route53", "dep:aws-sdk-s3", "dep:aws-sdk-sts"]

## Subcommands
dyndns = ["aws", "dep:local-ip-address", "dep:ip_network"]
sign = ["dep:hex", "dep:leon", "dep:minisign"]
crypto = ["dep:hex", "dep:leon", "dep:minisign"]
tamanu = ["dep:leon", "dep:leon-macros"]
upload = ["aws"]
wifisetup = ["dep:networkmanager"]
Expand Down
12 changes: 6 additions & 6 deletions src/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ pub mod completions;
pub mod context;
#[cfg(feature = "dyndns")]
pub mod dyndns;
#[cfg(feature = "sign")]
pub mod sign;
#[cfg(feature = "crypto")]
pub mod crypto;
#[cfg(feature = "tamanu")]
pub mod tamanu;
#[cfg(feature = "upload")]
Expand All @@ -25,8 +25,8 @@ pub enum Action {
Completions(completions::CompletionsArgs),
#[cfg(feature = "dyndns")]
Dyndns(dyndns::DyndnsArgs),
#[cfg(feature = "sign")]
Sign(sign::SignArgs),
#[cfg(feature = "crypto")]
Crypto(crypto::CryptoArgs),
#[cfg(feature = "tamanu")]
Tamanu(tamanu::TamanuArgs),
#[cfg(feature = "upload")]
Expand All @@ -44,8 +44,8 @@ pub async fn run() -> Result<()> {
(Action::Completions(args), ctx) => completions::run(ctx.with_top(args)).await,
#[cfg(feature = "dyndns")]
(Action::Dyndns(args), ctx) => dyndns::run(ctx.with_top(args)).await,
#[cfg(feature = "sign")]
(Action::Sign(args), ctx) => sign::run(ctx.with_top(args)).await,
#[cfg(feature = "crypto")]
(Action::Crypto(args), ctx) => crypto::run(ctx.with_top(args)).await,
#[cfg(feature = "tamanu")]
(Action::Tamanu(args), ctx) => tamanu::run(ctx.with_top(args)).await,
#[cfg(feature = "upload")]
Expand Down
34 changes: 34 additions & 0 deletions src/actions/crypto.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
use clap::{Parser, Subcommand};
use miette::Result;

use super::Context;

pub mod check;
pub mod sign;
pub mod keygen;

mod inout_args;
mod key_args;

/// Cryptographic operations.
#[derive(Debug, Clone, Parser)]
pub struct CryptoArgs {
/// Crypto subcommand
#[command(subcommand)]
pub action: CryptoAction,
}

#[derive(Debug, Clone, Subcommand)]
pub enum CryptoAction {
Verify(check::CheckArgs),
Sign(sign::SignArgs),
Keygen(keygen::KeygenArgs),
}

pub async fn run(ctx: Context<SignArgs>) -> Result<()> {
match ctx.args_top.action.clone() {
CryptoAction::Check(subargs) => check::run(ctx.with_sub(subargs)).await,
CryptoAction::Sign(subargs) => sign::run(ctx.with_sub(subargs)).await,
CryptoAction::Keygen(subargs) => keygen::run(ctx.with_sub(subargs)).await,
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions src/actions/sign/files.rs → src/actions/crypto/sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ use tracing::debug;

use super::{inout_args::inout_files, key_args::SecretKeyArgs, Context, SignArgs};

/// Sign a file or data with a secret key.
/// Sign files with a secret key.
#[derive(Debug, Clone, Parser)]
pub struct FilesArgs {
pub struct SignArgs {
/// A file to sign.
///
/// You can provide this multiple times to sign multiple files.
Expand Down Expand Up @@ -45,8 +45,8 @@ pub struct FilesArgs {
pub comment: Option<String>,
}

pub async fn run(ctx: Context<SignArgs, FilesArgs>) -> Result<()> {
let FilesArgs {
pub async fn run(ctx: Context<SignArgs, SignArgs>) -> Result<()> {
let SignArgs {
files,
key,
output,
Expand Down
34 changes: 0 additions & 34 deletions src/actions/sign.rs

This file was deleted.

0 comments on commit 6aa4835

Please sign in to comment.