diff options
| author | Sébastien d'Herbais de Thun <sebastien.d.herbais@gmail.com> | 2023-04-23 14:33:56 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-23 14:33:56 +0200 |
| commit | 561ff979d574f496415c0499345d41da2e1f6e1e (patch) | |
| tree | 037479ac000bd87a1cb2149e5389b28f08d24051 /cli/src/args.rs | |
| parent | 2fbb14f712708188649181525813b3ac5a02e0fb (diff) | |
Add instrumentation (Part 1) (#761)
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 |
