libroast/operations/
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
use crate::common::Compression;
use clap::Parser;
use std::path::PathBuf;
#[allow(unused_imports)]
use tracing::{
    debug,
    error,
    info,
    trace,
    warn,
    Level,
};

#[derive(Debug, Parser)]
#[command(
    name = "roast",
    author = "Soc Virnyl Estela",
    about = "Archiver with high-level compression",
    after_long_help = "Set verbosity and tracing through `RUST_LOG` environmental variable e.g. \
                       `RUST_LOG=trace`",
    help_template = "{name} {version} - \
                     {about}\n\n{usage}\n\n{all-args}\n{after-help}\nMaintained by {author} \
                     <contact@uncomfyhalomacro.pl>.",
    version
)]
pub struct RoastArgs
{
    #[arg(
        long,
        short = 't',
        help = "Target directory to archive. This will be set as the root directory of the \
                archive. Supports globbing."
    )]
    pub target: PathBuf,
    #[arg(
        long,
        short = 'i',
        help = "Additional paths such as files or directories in the target directory to include \
                to the archive. Their parent directory will be put next to the target directory's \
                work directory. The work directory is based on the preserve root option. This is \
                different from `--additional_paths`. Useful to override excluded directories. ⚠️ \
                Careful if the archive has whether preserved root set when it was created."
    )]
    pub include: Option<Vec<PathBuf>>,
    #[arg(
        long,
        short = 'E',
        help = "Additional paths such as files or directories from within target directory's work \
                directory to exclude when generating the archive."
    )]
    pub exclude: Option<Vec<PathBuf>>,
    #[arg(
        long,
        short = 'A',
        help = "Additional paths such as files or directories to add to the archive. Their parent \
                directory will be put next to the target directory. This is different from \
                `--include`. Optionally, one can add a path to a directory inside the archive \
                e.g. `-A some/file/to/archive,put/where/in/archive`. If directory does not exist, \
                it will be created."
    )]
    pub additional_paths: Option<Vec<String>>,
    #[arg(long, short = 'f', help = "Output file of the generated archive with path.")]
    pub outfile: PathBuf,
    #[arg(long, short = 'd', help = "Output path of extracted archive.")]
    pub outdir: Option<PathBuf>,
    #[arg(
        long,
        short = 'p',
        help = "Preserve root directory instead of only archiving relative paths.",
        default_value_t = false,
        action = clap::ArgAction::Set
    )]
    pub preserve_root: bool,
    #[arg(
        long,
        short = 'r',
        help = "Allow reproducibility for Reproducible Builds.",
        default_value_t = false,
        action = clap::ArgAction::Set
    )]
    pub reproducible: bool,
    #[arg(
        long,
        short = 'g',
        help = "Whether to ignore git related metadata, files and directories.",
        default_value_t = true,
        action = clap::ArgAction::Set
    )]
    pub ignore_git: bool,
    #[arg(
        long,
        short = 'I',
        help = "Whether to ignore hidden directories and files or what we call dotfiles. Does not affect `--ignore-git`.",
        default_value_t = false,
        action = clap::ArgAction::Set
    )]
    pub ignore_hidden: bool,
}

#[derive(Debug, Parser)]
#[command(
    name = "raw",
    author = "Soc Virnyl Estela",
    about = "Raw extractor and decompressor",
    after_long_help = "Set verbosity and tracing through `RUST_LOG` environmental variable e.g. \
                       `RUST_LOG=trace`",
    help_template = "{name} {version} - \
                     {about}\n\n{usage}\n\n{all-args}\n{after-help}\nMaintained by {author} \
                     <contact@uncomfyhalomacro.pl>.",
    version
)]
pub struct RawArgs
{
    #[arg(
        long,
        short = 't',
        help = "Target tarball file to extract and decompress. Supports globbing."
    )]
    pub target: PathBuf,
    #[arg(long, short = 'd', help = "Output directory of extracted archive.")]
    pub outdir: Option<PathBuf>,
}

#[derive(Debug, Parser)]
#[command(
    name = "recomprizz",
    author = "Soc Virnyl Estela",
    about = "Recompress to other compression formats",
    after_long_help = "Set verbosity and tracing through `RUST_LOG` environmental variable e.g. \
                       `RUST_LOG=trace`",
    help_template = "{name} {version} - \
                     {about}\n\n{usage}\n\n{all-args}\n{after-help}\nMaintained by {author} \
                     <contact@uncomfyhalomacro.pl>.",
    version
)]
pub struct RecomprizzArgs
{
    #[arg(
        long,
        short = 't',
        help = "Target tarball file to extract and recompress. Supports globbing."
    )]
    pub target: PathBuf,
    #[arg(
        long,
        short = 'i',
        help = "Additional paths such as files or directories in the target directory to include \
                to the archive. Their parent directory will be put next to the target directory's \
                work directory. The work directory is based on the preserve root option. This is \
                different from `--additional_paths`. Useful to override excluded directories."
    )]
    pub include: Option<Vec<PathBuf>>,
    #[arg(
        long,
        short = 'E',
        help = "Additional paths such as files or directories from within target directory's work \
                directory to exclude when generating the archive. ⚠️ Careful if the archive has \
                whether preserved root set when it was created."
    )]
    pub exclude: Option<Vec<PathBuf>>,
    #[arg(
        long,
        short = 'A',
        help = "Additional paths such as files or directories to add to the archive. Their parent \
                directory will be put next to the target directory. This is different from \
                `--include`. Optionally, one can add a path to a directory inside the archive \
                e.g. `-A some/file/to/archive,put/where/in/archive`. If directory does not exist, \
                it will be created."
    )]
    pub additional_paths: Option<Vec<String>>,
    #[arg(long, short = 'd', help = "Output directory of recompressed archive.")]
    pub outdir: Option<PathBuf>,
    #[arg(long, short = 'c', help = "Compression to use.", default_value_t)]
    pub compression: Compression,
    #[arg(
        long,
        short = 'R',
        help = "Use this flag if you want a new filename to use ignoring the new file extension. \
                Omitting this flag will just fallback to basename."
    )]
    pub rename: Option<String>,
    #[arg(
        long,
        short = 'r',
        help = "Allow reproducibility for Reproducible Builds.",
        default_value_t = false,
        action = clap::ArgAction::Set
    )]
    pub reproducible: bool,
    #[arg(
        long,
        short = 'g',
        help = "Whether to ignore git related metadata, files and directories.",
        default_value_t = true,
        action = clap::ArgAction::Set
    )]
    pub ignore_git: bool,
    #[arg(
        long,
        short = 'I',
        help = "Whether to ignore hidden directories and files or what we call dotfiles. Does not affect `--ignore-git`.",
        default_value_t = false,
        action = clap::ArgAction::Set
    )]
    pub ignore_hidden: bool,
}