diff options
Diffstat (limited to 'crates/typst-cli/src/main.rs')
| -rw-r--r-- | crates/typst-cli/src/main.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/crates/typst-cli/src/main.rs b/crates/typst-cli/src/main.rs index 283d17e2..b14e687e 100644 --- a/crates/typst-cli/src/main.rs +++ b/crates/typst-cli/src/main.rs @@ -2,6 +2,7 @@ mod args; mod compile; mod download; mod fonts; +mod greet; mod init; mod package; mod query; @@ -16,6 +17,7 @@ use std::cell::Cell; use std::io::{self, Write}; use std::process::ExitCode; +use clap::error::ErrorKind; use clap::Parser; use codespan_reporting::term; use codespan_reporting::term::termcolor::WriteColor; @@ -30,8 +32,15 @@ thread_local! { static EXIT: Cell<ExitCode> = const { Cell::new(ExitCode::SUCCESS) }; } -/// The parsed commandline arguments. -static ARGS: Lazy<CliArguments> = Lazy::new(CliArguments::parse); +/// The parsed command line arguments. +static ARGS: Lazy<CliArguments> = Lazy::new(|| { + CliArguments::try_parse().unwrap_or_else(|error| { + if error.kind() == ErrorKind::DisplayHelpOnMissingArgumentOrSubcommand { + crate::greet::greet(); + } + error.exit(); + }) +}); /// Entry point. fn main() -> ExitCode { |
