Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use clap::{Parser, Subcommand};
use clap::{Parser, Subcommand, ArgAction};
use gpgme::{Context, Protocol};
use rusqlite::Connection;
use std::fs;
Expand Down Expand Up @@ -34,13 +34,35 @@ pub enum Commands {
#[command(subcommand)]
action: SecretsCommands,
},
/// Encrypt yaml/json fields
Sops {
#[command(subcommand)]
action: SopsCommand,
},
/// Key validation and diagnostics
Keys {
#[command(subcommand)]
action: KeysCommands,
},
}

#[derive(Subcommand)]
pub enum SopsCommand {
/// Encrypt yaml/json file
Encrypt{
/// File name
file: String,
/// Optional path to fields, by default encrypt all fields
#[arg(short, long, action = ArgAction::Append)]
nodes: Vec<String>
},
/// Decrypt yaml/json file
Decrypt {
/// File name
file: String,
},
}

#[derive(Subcommand)]
pub enum SecretsCommands {
/// Add new secret to vault
Expand Down Expand Up @@ -796,6 +818,17 @@ impl DataManager {
}
}

fn handle_sops_command(action: SopsCommand) -> Result<(), DmError> {
match action {
SopsCommand::Encrypt { file, nodes } => {
Ok(())
}
SopsCommand::Decrypt { file } => {
Ok(())
}
}
}

fn handle_secrets_command(action: SecretsCommands) -> Result<(), DmError> {
match action {
SecretsCommands::Add { name, value, tags } => {
Expand Down Expand Up @@ -873,6 +906,7 @@ fn main() {
Commands::File { action } => handle_file_command(action),
Commands::Keys { action } => handle_key_command(action),
Commands::Secret { action } => handle_secrets_command(action),
Commands::Sops { action } => handle_sops_command(action),
};
if let Err(error) = result {
eprintln!("{}", error);
Expand Down