1 // Macros should be declared first
13 /// CLI argparsing definitions, using `clap`.
16 use std::{env, path::PathBuf};
18 use error::{Error, Result};
19 use once_cell::sync::Lazy;
20 use opts::{Opts, Subcommand};
21 use utils::{QuestionAction, QuestionPolicy};
23 // Used in BufReader and BufWriter to perform less syscalls
24 const BUFFER_CAPACITY: usize = 1024 * 32;
26 /// Current directory or empty directory
27 static CURRENT_DIRECTORY: Lazy<PathBuf> = Lazy::new(|| env::current_dir().unwrap_or_default());
29 /// The status code returned from `ouch` on error
30 pub const EXIT_FAILURE: i32 = libc::EXIT_FAILURE;
33 if let Err(err) = run() {
35 std::process::exit(EXIT_FAILURE);
39 fn run() -> Result<()> {
40 let (args, skip_questions_positively, file_visibility_policy) = Opts::parse_args()?;
41 commands::run(args, skip_questions_positively, file_visibility_policy)