aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorRuben Beltran del Rio <jj@r.bdr.sh>2026-04-30 15:17:30 +0200
committerRuben Beltran del Rio <jj@r.bdr.sh>2026-04-30 15:37:23 +0200
commit8cc11c52a88ec78d175b3ec8de854916f631caab (patch)
tree4ad0bc1664a97418d0475b0b730c54d874953348 /src/main.rs
Initial build
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
new file mode 100644
index 0000000..223fd24
--- /dev/null
+++ b/src/main.rs
@@ -0,0 +1,35 @@
+use std::env;
+use std::process::ExitCode;
+
+mod cleanup;
+mod render;
+mod serve;
+
+fn main() -> ExitCode {
+ let args: Vec<String> = env::args().collect();
+ let command = args.get(1).map(String::as_str);
+
+ match command {
+ None => serve::run(),
+ Some("--run") => {
+ if let Some(dir) = args.get(2) {
+ cleanup::run(dir)
+ } else {
+ eprintln!("estampa: --run requires a directory argument");
+ print_usage();
+ ExitCode::from(2)
+ }
+ }
+ Some(other) => {
+ eprintln!("estampa: unknown argument '{other}'");
+ print_usage();
+ ExitCode::from(2)
+ }
+ }
+}
+
+fn print_usage() {
+ eprintln!("usage:");
+ eprintln!(" estampa serve a paste via CGI (DOCUMENT_ROOT + DOCUMENT_URI)");
+ eprintln!(" estampa --run <directory> delete files older than one week");
+}