add list command

This commit is contained in:
Wim Velzeboer
2026-09-07 10:52:43 +01:00
parent 1d37b13941
commit 578f23001c
3 changed files with 68 additions and 36 deletions
+34 -3
View File
@@ -1,7 +1,7 @@
use crate::logger; use crate::logger;
use anyhow::{Context, Result}; use anyhow::{Context, Result};
use clap::{CommandFactory, Parser, ValueEnum}; use clap::{Parser, ValueEnum};
use log::{error, info}; use log::error;
#[derive(Parser, Debug)] #[derive(Parser, Debug)]
#[command(version, about, long_about = None)] #[command(version, about, long_about = None)]
@@ -28,6 +28,9 @@ enum Commands {
/// Controls testing features /// Controls testing features
FileSync, FileSync,
/// Lists the settings from the configuration file
List,
/// Change Settings /// Change Settings
Set { Set {
#[command(subcommand)] #[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("<not set>")
);
Ok(())
}
fn set_sfdx_auth_url(config_file: &str, url: String) -> Result<()> { fn set_sfdx_auth_url(config_file: &str, url: String) -> Result<()> {
let mut app_config = let mut app_config =
crate::config::load(config_file).context("Failed to load application configuration")?; 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(()) Ok(())
} }
pub(crate) fn run() { pub(crate) fn run() {
let cli = Cli::parse(); let cli = Cli::parse();
@@ -171,6 +189,9 @@ pub(crate) fn run() {
Commands::Set { command } => { Commands::Set { command } => {
run_set_command(&cli, command); run_set_command(&cli, command);
}, },
Commands::List => {
run_list_command(&cli);
},
Commands::FileSync { .. } => { Commands::FileSync { .. } => {
run_file_sync(&cli); run_file_sync(&cli);
} }
@@ -196,6 +217,16 @@ fn run_file_sync(cli: &Cli) {
crate::file_sync::run(); 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<SettingsCommands>) { fn run_set_command(cli: &Cli, commands: &Option<SettingsCommands>) {
match commands { match commands {
Some(command) => match command { Some(command) => match command {
+34
View File
@@ -1,3 +1,37 @@
pub fn run() { pub fn run() {
unimplemented!("File sync not yet implemented"); 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.");*/
} }
-33
View File
@@ -23,37 +23,4 @@ pub static APP_CONFIG: OnceLock<config::AppConfig> = OnceLock::new();
#[::tokio::main] #[::tokio::main]
async fn main() { async fn main() {
cli::run(); 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.");*/
} }