From 603eb616bb65636ed5d69353c7dd28f5d4c6f52b Mon Sep 17 00:00:00 2001 From: Alexey Nikandrov Date: Mon, 11 Aug 2025 08:05:34 +0300 Subject: [PATCH] Init SOPS commands skeleton Signed-off-by: Alexey Nikandrov --- src/main.rs | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index dc4c59d..cc192f9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,4 @@ -use clap::{Parser, Subcommand}; +use clap::{Parser, Subcommand, ArgAction}; use gpgme::{Context, Protocol}; use rusqlite::Connection; use std::fs; @@ -34,6 +34,11 @@ pub enum Commands { #[command(subcommand)] action: SecretsCommands, }, + /// Encrypt yaml/json fields + Sops { + #[command(subcommand)] + action: SopsCommand, + }, /// Key validation and diagnostics Keys { #[command(subcommand)] @@ -41,6 +46,23 @@ pub enum Commands { }, } +#[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 + }, + /// Decrypt yaml/json file + Decrypt { + /// File name + file: String, + }, +} + #[derive(Subcommand)] pub enum SecretsCommands { /// Add new secret to vault @@ -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 } => { @@ -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);