From 578f23001cfcc091f7b6c55471d659b51d449156 Mon Sep 17 00:00:00 2001 From: Wim Velzeboer Date: Mon, 7 Sep 2026 10:52:43 +0100 Subject: [PATCH] add list command --- src/cli/mod.rs | 37 ++++++++++++++++++++++++++++++++++--- src/file_sync/mod.rs | 34 ++++++++++++++++++++++++++++++++++ src/main.rs | 33 --------------------------------- 3 files changed, 68 insertions(+), 36 deletions(-) diff --git a/src/cli/mod.rs b/src/cli/mod.rs index 072cd59..5ab76d2 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -1,7 +1,7 @@ use crate::logger; use anyhow::{Context, Result}; -use clap::{CommandFactory, Parser, ValueEnum}; -use log::{error, info}; +use clap::{Parser, ValueEnum}; +use log::error; #[derive(Parser, Debug)] #[command(version, about, long_about = None)] @@ -28,6 +28,9 @@ enum Commands { /// Controls testing features FileSync, + /// Lists the settings from the configuration file + List, + /// Change Settings Set { #[command(subcommand)] @@ -150,6 +153,22 @@ fn load_configuration_file(config_file: &str) -> Result<()> { } +fn list_config_settings(config_file: &str) -> Result<()> { + let app_config = + crate::config::load(config_file).context("Failed to load application configuration")?; + + println!("Configuration: {config_file}"); + println!( + "sfdx_auth_url = {}", + app_config + .sfdx_auth_url + .as_deref() + .unwrap_or("") + ); + + Ok(()) +} + fn set_sfdx_auth_url(config_file: &str, url: String) -> Result<()> { let mut app_config = crate::config::load(config_file).context("Failed to load application configuration")?; @@ -162,7 +181,6 @@ fn set_sfdx_auth_url(config_file: &str, url: String) -> Result<()> { Ok(()) } - pub(crate) fn run() { let cli = Cli::parse(); @@ -171,6 +189,9 @@ pub(crate) fn run() { Commands::Set { command } => { run_set_command(&cli, command); }, + Commands::List => { + run_list_command(&cli); + }, Commands::FileSync { .. } => { run_file_sync(&cli); } @@ -196,6 +217,16 @@ fn run_file_sync(cli: &Cli) { crate::file_sync::run(); } +fn run_list_command(cli: &Cli) { + match list_config_settings(&cli.config) { + Ok(()) => {} + Err(e) => { + error!("Error listing configuration settings: {:#}", e); + std::process::exit(1); + } + } +} + fn run_set_command(cli: &Cli, commands: &Option) { match commands { Some(command) => match command { diff --git a/src/file_sync/mod.rs b/src/file_sync/mod.rs index d7b760c..67fcfb4 100644 --- a/src/file_sync/mod.rs +++ b/src/file_sync/mod.rs @@ -1,3 +1,37 @@ pub fn run() { unimplemented!("File sync not yet implemented"); + + /* +let args = cli::Args::parse(); + + + + +let salesforce_client = salesforce::connect(&args.sfdx_auth_url).await?; +let s3_client = aws_s3::connect( + args.s3_client_id(), + args.s3_client_secret(), + args.s3_endpoint(), + args.s3_region(), +); + + +salesforce_client.query(r#"SELECT Id, Title, FileType, FileExtension, Description, +ContentLocation, Origin, VersionData, ContentDocumentId, FirstPublishLocationId, PathOnClient + FROM ContentVersion + WHERE IsMajorVersion = TRUE + AND ContentLocation = 'S' + LIMIT 1\ +"#) + + + +if terminator::CONFIG.is_fired() { + info!("Received termination signal, exiting..."); +} + + + +info!("Done.");*/ + } \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 57d603e..72312dd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,37 +23,4 @@ pub static APP_CONFIG: OnceLock = OnceLock::new(); #[::tokio::main] async fn main() { cli::run(); - /* - let args = cli::Args::parse(); - - - - - let salesforce_client = salesforce::connect(&args.sfdx_auth_url).await?; - let s3_client = aws_s3::connect( - args.s3_client_id(), - args.s3_client_secret(), - args.s3_endpoint(), - args.s3_region(), - ); - - - salesforce_client.query(r#"SELECT Id, Title, FileType, FileExtension, Description, - ContentLocation, Origin, VersionData, ContentDocumentId, FirstPublishLocationId, PathOnClient - FROM ContentVersion - WHERE IsMajorVersion = TRUE - AND ContentLocation = 'S' - LIMIT 1\ - "#) - - - - if terminator::CONFIG.is_fired() { - info!("Received termination signal, exiting..."); - } - - - - info!("Done.");*/ - }