diff options
Diffstat (limited to 'cli/src/args.rs')
| -rw-r--r-- | cli/src/args.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/cli/src/args.rs b/cli/src/args.rs index 42d52140..699dbb97 100644 --- a/cli/src/args.rs +++ b/cli/src/args.rs @@ -17,6 +17,10 @@ pub struct CliArguments { /// The typst command to run #[command(subcommand)] pub command: Command, + + /// Sets the level of verbosity: 0 = none, 1 = warning & error, 2 = info, 3 = debug, 4 = trace + #[clap(short, long, action = ArgAction::Count)] + pub verbosity: u8, } /// What to do. @@ -35,6 +39,22 @@ pub enum Command { Fonts(FontsCommand), } +impl Command { + /// Returns the compile command if this is a compile or watch command. + pub fn as_compile(&self) -> Option<&CompileCommand> { + match self { + Command::Compile(cmd) => Some(cmd), + Command::Watch(cmd) => Some(cmd), + Command::Fonts(_) => None, + } + } + + /// Returns whether this is a watch command. + pub fn is_watch(&self) -> bool { + matches!(self, Command::Watch(_)) + } +} + /// Compiles the input file into a PDF file #[derive(Debug, Clone, Parser)] pub struct CompileCommand { @@ -47,6 +67,11 @@ pub struct CompileCommand { /// Opens the output file after compilation using the default PDF viewer #[arg(long = "open")] pub open: Option<Option<String>>, + + /// Produces a flamegraph of the compilation process and saves it to the + /// given file or to `flamegraph.svg` in the current working directory. + #[arg(long = "flamegraph", value_name = "OUTPUT_SVG")] + pub flamegraph: Option<Option<PathBuf>>, } /// List all discovered fonts in system and custom font paths |
