summaryrefslogtreecommitdiff
path: root/oryxc/src/main.rs
diff options
context:
space:
mode:
authorromir kulshrestha <romir.kulshrestha@gmail.com> 2026-03-04 19:54:34 +0100
committerromir kulshrestha <romir.kulshrestha@gmail.com> 2026-03-04 19:54:34 +0100
commit9d0c4a673036e48b4d8a455eb468806e9087fb4e (patch)
tree8301ed4dca9001fe423889626920ce661cfbe774 /oryxc/src/main.rs
parentcb792e04c739aa0ea1e957595508b5d2b42fe1c2 (diff)
multiline usage
Diffstat (limited to 'oryxc/src/main.rs')
-rw-r--r--oryxc/src/main.rs21
1 files changed, 19 insertions, 2 deletions
diff --git a/oryxc/src/main.rs b/oryxc/src/main.rs
index b5c63cf..7320c19 100644
--- a/oryxc/src/main.rs
+++ b/oryxc/src/main.rs
@@ -10,7 +10,11 @@ mod unicode;
use std::ffi::OsString;
use std::thread;
-use clap::Parser;
+use clap::{
+ CommandFactory,
+ FromArgMatches,
+ Parser,
+};
#[derive(Clone, Copy, Default)]
pub struct Flags {
@@ -38,7 +42,10 @@ struct Args {
}
fn main() {
- let args = Args::parse();
+ let args = Args::from_arg_matches(
+ &Args::command().override_usage(usage()).get_matches(),
+ )
+ .unwrap_or_else(|e| e.exit());
let threads = args.threads.unwrap_or_else(|| {
thread::available_parallelism().map_or_else(
@@ -64,3 +71,13 @@ fn main() {
let _ = errors::ERROR_STYLE.set(flags.error_style);
compiler::start(args.files, flags);
}
+
+fn usage() -> String {
+ format!(
+ concat!(
+ "Usage: {0} [-lp] [-s oneline|standard] [-t threads]\n",
+ " {0} -h",
+ ),
+ errors::progname().display()
+ )
+}