dn_lib/
cli.rs

1// SPDX-FileCopyrightText: 2024-2025 Matthew Mark Ibbetson
2// SPDX-FileContributor: Matthew Mark Ibbetson
3//
4// SPDX-License-Identifier: GPL-3.0-or-later
5
6//! CLAP-derive struct definition specifying the command line interface for dn.
7
8use clap::{ArgAction, Parser, Subcommand};
9
10#[derive(Parser)]
11#[command(
12    name = "dn",
13    version = "0.1.3",
14    about = "A command to manage notes following the Denote naming scheme"
15)]
16pub struct Cli {
17    #[command(subcommand)]
18    pub command: Commands,
19}
20
21#[derive(Subcommand)]
22pub enum Commands {
23    /// Create a new note
24    New {
25        /// Print the absolute path of the created note
26        #[arg(
27            short = 'p',
28            long = "print",
29            action = ArgAction::SetTrue,
30        )]
31        cli_print: bool,
32
33        /// Directory in which the note will be created
34        #[arg(
35            short = 'd',
36            long = "directory",
37            value_name = "PATH",
38            action = ArgAction::Set,
39        )]
40        cli_directory_path: Option<String>,
41
42        /// Configuration file path
43        #[arg(
44            short = 'c',
45            long = "config",
46            value_name = "PATH",
47            action = ArgAction::Set,
48        )]
49        cli_config_path: Option<String>,
50
51        /// Template file to add contents to new note
52        #[arg(
53            short = 'T',
54            long = "template",
55            value_name = "PATH",
56            action = ArgAction::Set,
57        )]
58        cli_template_path: Option<String>,
59
60        /// Signature for the note
61        #[arg(
62            short = 's',
63            long = "signature",
64            value_name = "SIGNATURE",
65            action = ArgAction::Set,
66        )]
67        cli_signature: Option<String>,
68
69        /// Title for the note
70        #[arg(
71            short = 't',
72            long = "title",
73            value_name = "TITLE",
74            action = ArgAction::Set,
75        )]
76        cli_title: Option<String>,
77
78        /// File extension for the note
79        #[arg(
80            short = 'e',
81            long = "extension",
82            value_name = "EXTENSION",
83            action = ArgAction::Set,
84        )]
85        cli_extension: Option<String>,
86
87        /// Keywords for the note
88        #[arg(
89            short = 'k',
90            long = "keywords",
91            value_name = "KEYWORD(S)",
92            action = ArgAction::Set,
93        )]
94        cli_keywords: Option<String>,
95    },
96
97    /// Rename an existing note
98    Rename {
99        /// Path to the input file to be renamed
100        input: String,
101
102        /// Print the absolute path of the created file
103        #[arg(
104            short = 'p',
105            long = "print",
106            action = ArgAction::SetTrue,
107        )]
108        cli_print: bool,
109
110        /// Generate an identifier even if there is an existing one
111        #[arg(
112            short = 'I',
113            long = "regenerate-identifier",
114            action = ArgAction::SetTrue,
115        )]
116        cli_regenerate_identifier: bool,
117
118        /// Configuration file path
119        #[arg(
120            short = 'c',
121            long = "config",
122            value_name = "PATH",
123            action = ArgAction::Set,
124        )]
125        cli_config_path: Option<String>,
126
127        /// New signature for the note
128        #[arg(
129            short = 's',
130            long = "signature",
131            value_name = "SIGNATURE",
132            action = ArgAction::Set,
133        )]
134        cli_signature: Option<String>,
135
136        /// New title for the note
137        #[arg(
138            short = 't',
139            long = "title",
140            value_name = "TITLE",
141            action = ArgAction::Set,
142        )]
143        cli_title: Option<String>,
144
145        /// New keywords for the note
146        #[arg(
147            short = 'k',
148            long = "keywords",
149            value_name = "KEYWORDS",
150            action = ArgAction::Set,
151        )]
152        cli_keywords: Option<String>,
153
154        /// Add keywords to the current or new keywords
155        #[arg(
156            short = 'A',
157            long = "add-keywords",
158            value_name = "KEYWORDS",
159            action = ArgAction::Set,
160        )]
161        cli_add_keywords: Option<String>,
162
163        /// Remove keywords from the current or new keywords
164        #[arg(
165            short = 'R',
166            long = "remove-keywords",
167            value_name = "KEYWORDS",
168            action = ArgAction::Set,
169        )]
170        cli_remove_keywords: Option<String>,
171
172        /// New file extension for the note
173        #[arg(
174            short = 'e',
175            long = "extension",
176            value_name = "EXTENSION",
177            action = ArgAction::Set,
178        )]
179        cli_extension: Option<String>,
180    },
181}