summary refs log tree commit diff stats
path: root/src/cli.rs
blob: 12419d6360d31d2a232a160f701f905ea3f430d0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
use clap::{ArgAction, Parser, Subcommand};

/// A project manager for LaTeX
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
pub struct Args {
    #[command(subcommand)]
    pub cli: Command,

    /// Increase message verbosity
    #[arg(long="verbose", short = 'v', action = ArgAction::Count)]
    pub verbosity: u8,

    /// Silence all output
    #[arg(long, short = 'q')]
    pub quiet: bool,
}

#[derive(Subcommand, Debug)]
pub enum Command {
    /// Generates a new part
    #[command(subcommand)]
    New(What),

    /// Bundle the project into one TeX file
    ///
    /// This command has some known issues and invariants:
    /// - It does not consider, that `\include`s or `\input`s could be commented out.
    /// - It does also not consider the case, where `\include` or `\input` have been re-defined
    #[command(verbatim_doc_comment)]
    Bundle,
}

#[derive(Subcommand, Debug)]
pub enum What {
    /// Adds a section
    Section {
        /// The name of the chapter to extend, can be empty when the current_dir is inside a
        /// chapter already.
        #[arg(long, short)]
        chapter: Option<String>,

        /// Name of the new section
        name: String,
    },

    /// Adds a chapter
    Chapter {
        /// Name of the new chapter
        name: String,
    },

    /// Adds a figure
    Figure {
        /// Name of the new figure
        name: String,
    },
}