diff options
| author | figsoda <figsoda@pm.me> | 2023-04-06 14:14:01 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-06 20:14:01 +0200 |
| commit | 1c324765e92c23826dff4f37d3b01761a3ac6ef4 (patch) | |
| tree | 1c84390a6ff58545374b7cbfa3c74f82af306558 /cli/src/args.rs | |
| parent | 75461675c4e57675174d98060124c9e13beaf7e4 (diff) | |
Add shell completions and man pages (#582)
Diffstat (limited to 'cli/src/args.rs')
| -rw-r--r-- | cli/src/args.rs | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/cli/src/args.rs b/cli/src/args.rs new file mode 100644 index 00000000..c88c9a21 --- /dev/null +++ b/cli/src/args.rs @@ -0,0 +1,58 @@ +use std::path::PathBuf; + +use clap::{ArgAction, Parser, Subcommand}; + +/// typst creates PDF files from .typ files +#[derive(Debug, Clone, Parser)] +#[clap(name = "typst", version = crate::typst_version(), author)] +pub struct CliArguments { + /// Add additional directories to search for fonts + #[clap(long = "font-path", value_name = "DIR", action = ArgAction::Append)] + pub font_paths: Vec<PathBuf>, + + /// Configure the root for absolute paths + #[clap(long = "root", value_name = "DIR")] + pub root: Option<PathBuf>, + + /// The typst command to run + #[command(subcommand)] + pub command: Command, +} + +/// What to do. +#[derive(Debug, Clone, Subcommand)] +#[command()] +pub enum Command { + /// Compiles the input file into a PDF file + #[command(visible_alias = "c")] + Compile(CompileCommand), + + /// Watches the input file and recompiles on changes + #[command(visible_alias = "w")] + Watch(CompileCommand), + + /// List all discovered fonts in system and custom font paths + Fonts(FontsCommand), +} + +/// Compiles the input file into a PDF file +#[derive(Debug, Clone, Parser)] +pub struct CompileCommand { + /// Path to input Typst file + pub input: PathBuf, + + /// Path to output PDF file + pub output: Option<PathBuf>, + + /// Opens the output file after compilation using the default PDF viewer + #[arg(long = "open")] + pub open: Option<Option<String>>, +} + +/// List all discovered fonts in system and custom font paths +#[derive(Debug, Clone, Parser)] +pub struct FontsCommand { + /// Also list style variants of each font family + #[arg(long)] + pub variants: bool, +} |
