| 1 | mod artifacts; |
| 2 | mod cli; |
| 3 | mod client; |
| 4 | mod config; |
| 5 | mod daemon; |
| 6 | mod history; |
| 7 | mod hook; |
| 8 | mod paths; |
| 9 | mod proto; |
| 10 | mod run; |
| 11 | mod sched; |
| 12 | mod store; |
| 13 | mod sys; |
| 14 | #[cfg(target_os = "linux")] |
| 15 | mod systemd; |
| 16 | mod units; |
| 17 | |
| 18 | use pound::Parse; |
| 19 | |
| 20 | fn main() { |
| 21 | #[cfg(target_os = "linux")] |
| 22 | if let Some(code) = systemd::exec() { |
| 23 | std::process::exit(code); |
| 24 | } |
| 25 | // a typo must not exit 2, that's a blocking pretooluse verdict and would |
| 26 | // wall off every bash call in every session |
| 27 | let rabt = cli::Rabt::parse(); |
| 28 | let cfg = if matches!(&rabt, cli::Rabt::Daemon) { |
| 29 | config::Config::load() |
| 30 | } else { |
| 31 | let cwd = std::env::current_dir().unwrap_or_else(|_| "/".into()); |
| 32 | config::Config::load_for(&cwd) |
| 33 | } |
| 34 | .unwrap_or_else(|e| { |
| 35 | eprintln!("roundabout: bad config, using defaults. {e}"); |
| 36 | config::Config::default() |
| 37 | }); |
| 38 | std::process::exit(cli::dispatch(&cfg, rabt)); |
| 39 | } |