dn_lib/
cli.rs

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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
// SPDX-FileCopyrightText: 2024-2025 Matthew Mark Ibbetson
// SPDX-FileContributor: Matthew Mark Ibbetson
//
// SPDX-License-Identifier: GPL-3.0-or-later

//! CLAP-derive struct definition specifying the command line interface for dn.

use clap::{ArgAction, Parser, Subcommand};

#[derive(Parser)]
#[command(
    name = "dn",
    version = "0.1.0",
    about = "A command to manage notes following the Denote naming scheme"
)]
pub struct Cli {
    #[command(subcommand)]
    pub command: Commands,
}

#[derive(Subcommand)]
pub enum Commands {
    /// Create a new note
    New {
        /// Print the absolute path of the created note
        #[arg(
            short = 'p',
            long = "print",
            action = ArgAction::SetTrue,
        )]
        cli_print: bool,

        /// Directory in which the note will be created
        #[arg(
            short = 'd',
            long = "directory",
            value_name = "PATH",
            action = ArgAction::Set,
        )]
        cli_directory_path: Option<String>,

        /// Configuration file path
        #[arg(
            short = 'c',
            long = "config",
            value_name = "PATH",
            action = ArgAction::Set,
        )]
        cli_config_path: Option<String>,

        /// Template file to add contents to new note
        #[arg(
            short = 'T',
            long = "template",
            value_name = "PATH",
            action = ArgAction::Set,
        )]
        cli_template_path: Option<String>,

        /// Signature for the note
        #[arg(
            short = 's',
            long = "signature",
            value_name = "SIGNATURE",
            action = ArgAction::Set,
        )]
        cli_signature: Option<String>,

        /// Title for the note
        #[arg(
            short = 't',
            long = "title",
            value_name = "TITLE",
            action = ArgAction::Set,
        )]
        cli_title: Option<String>,

        /// File extension for the note
        #[arg(
            short = 'e',
            long = "extension",
            value_name = "EXTENSION",
            action = ArgAction::Set,
        )]
        cli_extension: Option<String>,

        /// Keywords for the note
        #[arg(
            short = 'k',
            long = "keywords",
            value_name = "KEYWORD(S)",
            action = ArgAction::Set,
        )]
        cli_keywords: Option<String>,
    },

    /// Rename an existing note
    Rename {
        /// Path to the input file to be renamed
        input: String,

        /// Print the absolute path of the created file
        #[arg(
            short = 'p',
            long = "print",
            action = ArgAction::SetTrue,
        )]
        cli_print: bool,

        /// Generate an identifier even if there is an existing one
        #[arg(
            short = 'I',
            long = "regenerate-identifier",
            action = ArgAction::SetTrue,
        )]
        cli_regenerate_identifier: bool,

        /// Configuration file path
        #[arg(
            short = 'c',
            long = "config",
            value_name = "PATH",
            action = ArgAction::Set,
        )]
        cli_config_path: Option<String>,

        /// New signature for the note
        #[arg(
            short = 's',
            long = "signature",
            value_name = "SIGNATURE",
            action = ArgAction::Set,
        )]
        cli_signature: Option<String>,

        /// New title for the note
        #[arg(
            short = 't',
            long = "title",
            value_name = "TITLE",
            action = ArgAction::Set,
        )]
        cli_title: Option<String>,

        /// New keywords for the note
        #[arg(
            short = 'k',
            long = "keywords",
            value_name = "KEYWORDS",
            action = ArgAction::Set,
        )]
        cli_keywords: Option<String>,

        /// Add keywords to the current or new keywords
        #[arg(
            short = 'A',
            long = "add-keywords",
            value_name = "KEYWORDS",
            action = ArgAction::Set,
        )]
        cli_add_keywords: Option<String>,

        /// Remove keywords from the current or new keywords
        #[arg(
            short = 'R',
            long = "remove-keywords",
            value_name = "KEYWORDS",
            action = ArgAction::Set,
        )]
        cli_remove_keywords: Option<String>,

        /// New file extension for the note
        #[arg(
            short = 'e',
            long = "extension",
            value_name = "EXTENSION",
            action = ArgAction::Set,
        )]
        cli_extension: Option<String>,
    },
}