Basic CLI Stuff

This commit is contained in:
Wim Velzeboer
2026-09-03 15:41:45 +01:00
commit a240e95adb
6 changed files with 286 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
/target
Generated
+186
View File
@@ -0,0 +1,186 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "anstream"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "824a212faf96e9acacdbd09febd34438f8f711fb84e09a8916013cd7815ca28d"
dependencies = [
"anstyle",
"anstyle-parse",
"anstyle-query",
"anstyle-wincon",
"colorchoice",
"is_terminal_polyfill",
"utf8parse",
]
[[package]]
name = "anstyle"
version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000"
[[package]]
name = "anstyle-parse"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "52ce7f38b242319f7cabaa6813055467063ecdc9d355bbb4ce0c68908cd8130e"
dependencies = [
"utf8parse",
]
[[package]]
name = "anstyle-query"
version = "1.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc"
dependencies = [
"windows-sys",
]
[[package]]
name = "anstyle-wincon"
version = "3.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d"
dependencies = [
"anstyle",
"once_cell_polyfill",
"windows-sys",
]
[[package]]
name = "clap"
version = "4.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "473c7e07f409a8d772161724aa8db6a765a2532a70f9667eeb7b49d3d02fbdca"
dependencies = [
"clap_builder",
"clap_derive",
]
[[package]]
name = "clap_builder"
version = "4.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b48fea5a88e9ae728a2dcbedbfc0e730f7d60da42e1cb049a83c9fb8b789889"
dependencies = [
"anstream",
"anstyle",
"clap_lex",
"strsim",
]
[[package]]
name = "clap_derive"
version = "4.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d012d2b9d65aca7f18f4d9878a045bc17899bba951561ba5ec3c2ba1eed9a061"
dependencies = [
"heck",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "clap_lex"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9"
[[package]]
name = "colorchoice"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570"
[[package]]
name = "heck"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
[[package]]
name = "imojefs"
version = "0.0.1"
dependencies = [
"clap",
]
[[package]]
name = "is_terminal_polyfill"
version = "1.70.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695"
[[package]]
name = "once_cell_polyfill"
version = "1.70.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"
[[package]]
name = "proc-macro2"
version = "1.0.107"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
dependencies = [
"proc-macro2",
]
[[package]]
name = "strsim"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
[[package]]
name = "syn"
version = "3.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6275cddf4610d1775e6d1fe9469b2e77d0f39fd98fb7450901b821e0c53649f"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "unicode-ident"
version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
[[package]]
name = "utf8parse"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
[[package]]
name = "windows-link"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
[[package]]
name = "windows-sys"
version = "0.61.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
dependencies = [
"windows-link",
]
+9
View File
@@ -0,0 +1,9 @@
[package]
name = "imojefs"
description = "Johnson & Johnson IMoje File Sync"
authors = ["Wim Velzeboer <wim@velzeboer.nl>"]
version = "0.0.1"
edition = "2024"
[dependencies]
clap = { version = "4.6.1", features = ["derive", "env"] }
+10
View File
@@ -0,0 +1,10 @@
# IMoje File Sync
```
.___ _____ __ ____________________
| | / \ ____ |__| ____\_ _____/ _____/
| |/ \ / \ / _ \ | |/ __ \| __) \_____ \
| / Y ( <_> ) | \ ___/| \ / \
|___\____|__ /\____/\__| |\___ >___ / /_______ /
\/ \______| \/ \/ \/
```
+66
View File
@@ -0,0 +1,66 @@
use clap::{Parser, ValueEnum};
#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
pub struct Args {
/// AWS Bucket name
#[arg(short = 'b', long, env = "IMOJEFS_S3_BUCKET")]
pub s3_bucket: String,
/// AWS Access Key Id
#[arg(short = 'k', long, env = "IMOJEFS_S3_CLIENT_ID")]
pub s3_key: String,
/// AWS Secret Access Key
#[arg(short = 's', long, env = "IMOJEFS_S3_SECRET", hide_env_values = true)]
pub s3_secret: String,
/// AWS Endpoint URL, [default: AWS url]
#[arg(short = 'e', long, env = "IMOJEFS_S3_ENDPOINT")]
pub s3_endpoint: Option<String>,
/// AWS Region
#[arg(short = 'r', long, default_value = "us-east-1", env = "IMOJEFS_S3_REGION")]
pub s3_region: String,
/// Salesforce Authentication Url
#[arg(short = 'x', long, env = "IMOJEFS_SFDX_AUTH_URL", hide_env_values = true)]
pub sfdx_auth_url: String,
/// Number of seconds to wait
#[arg(short = 'w', long, default_value_t = 20, env = "IMOJEFS_WAIT")]
pub wait: u64,
/// The logging level
#[arg(short = 'l', long, value_enum, default_value_t = LogLevel::Info, env = "IMOJEFS_LOG_LEVEL")]
pub log_level: LogLevel,
/// Retry failures after X runs
#[arg(long, default_value_t = 180, env = "IMOJEFS_RETRY")]
pub retry: u64,
/// A comma separated list of fallback email address,
/// used when Salesforce cannot be reached to deliver log messages
#[arg(short = 'a', long, env = "IMOJEFS_ADMIN_EMAIL")]
pub admin_email: Option<String>,
}
/// Represents the different levels of logging that can be used in an application.
///
/// # Variants
/// - `Debug`: Indicates detailed debugging information typically used for development and troubleshooting.
/// - `Info`: Represents general operational information, such as confirmation that things are working as expected.
/// - `Warning`: Denotes potentially harmful situations or actions that warrant attention but are not critical errors.
/// - `Error`: Designates severe error events that lead to application malfunction or require immediate resolution.
///
/// This enum derives `ValueEnum` to allow easy parsing from strings (e.g., for command-line arguments),
/// as well as `Clone` and `Debug` for efficient copying and debugging purposes.
#[derive(ValueEnum, Clone, Debug)]
pub enum LogLevel {
Debug,
Info,
Warning,
Error,
Trace,
}
+14
View File
@@ -0,0 +1,14 @@
//! # IMoje File Sync
//!
//! Syncs the contents of a Salesforce File to S3
use clap::Parser;
mod cli;
fn main() {
let args = cli::Args::parse();
println!("Hello, world!");
}