Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c0352c2

Browse files
committed
Move common flags to common plac
1 parent ed5882d commit c0352c2

3 files changed

Lines changed: 24 additions & 66 deletions

File tree

src/plumbing/lean.rs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ mod options {
1111
/// print the program version.
1212
pub version: bool,
1313

14+
/// display verbose messages and progress information
15+
#[argh(switch, short = 'v')]
16+
pub verbose: bool,
17+
1418
#[argh(option, short = 't')]
1519
/// the amount of threads to use for some operations.
1620
///
@@ -34,10 +38,6 @@ mod options {
3438
#[derive(FromArgs, PartialEq, Debug)]
3539
#[argh(subcommand, name = "index-from-pack")]
3640
pub struct IndexFromPack {
37-
/// display verbose messages and progress information
38-
#[argh(switch, short = 'v')]
39-
pub verbose: bool,
40-
4141
/// specify how to iterate the pack, defaults to 'verify'
4242
///
4343
/// Valid values are
@@ -79,10 +79,6 @@ mod options {
7979
#[argh(switch)]
8080
pub delete_pack: bool,
8181

82-
/// display verbose messages and progress information
83-
#[argh(switch, short = 'v')]
84-
pub verbose: bool,
85-
8682
/// compress bytes even when using the sink, i.e. no object directory is specified
8783
///
8884
/// This helps to determine overhead related to compression. If unset, the sink will
@@ -139,9 +135,6 @@ mod options {
139135
/// output statistical information about the pack
140136
#[argh(switch, short = 's')]
141137
pub statistics: bool,
142-
/// display verbose messages and progress information
143-
#[argh(switch, short = 'v')]
144-
pub verbose: bool,
145138
/// the '.pack' or '.idx' file whose checksum to validate.
146139
#[argh(positional)]
147140
pub path: PathBuf,
@@ -188,9 +181,9 @@ pub fn main() -> Result<()> {
188181
pub use options::*;
189182
let cli: Args = crate::shared::from_env();
190183
let thread_limit = cli.threads;
184+
let verbose = cli.verbose;
191185
match cli.subcommand {
192186
SubCommands::IndexFromPack(IndexFromPack {
193-
verbose,
194187
iteration_mode,
195188
pack_path,
196189
directory,
@@ -210,7 +203,6 @@ pub fn main() -> Result<()> {
210203
pack_path,
211204
sink_compress,
212205
object_path,
213-
verbose,
214206
verify,
215207
check,
216208
delete_pack,
@@ -231,7 +223,6 @@ pub fn main() -> Result<()> {
231223
}
232224
SubCommands::PackVerify(PackVerify {
233225
path,
234-
verbose,
235226
statistics,
236227
algorithm,
237228
decode,

src/plumbing/pretty.rs

Lines changed: 18 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,20 @@ mod options {
2121
/// If unset, or the value is 0, there is no limit and all logical cores can be used.
2222
pub threads: Option<usize>,
2323

24+
/// Display verbose messages and progress information
25+
#[structopt(long, short = "v")]
26+
pub verbose: bool,
27+
28+
/// Bring up a terminal user interface displaying progress visually
29+
#[structopt(long, conflicts_with("verbose"))]
30+
pub progress: bool,
31+
32+
/// The progress TUI will stay up even though the work is already completed.
33+
///
34+
/// Use this to be able to read progress messages or additional information visible in the TUI log pane.
35+
#[structopt(long, conflicts_with("verbose"), requires("progress"))]
36+
pub progress_keep_open: bool,
37+
2438
#[structopt(subcommand)]
2539
pub cmd: Subcommands,
2640
}
@@ -32,20 +46,6 @@ mod options {
3246
/// This command can also be used to stream packs to standard input or to repair partial packs.
3347
#[structopt(setting = AppSettings::ColoredHelp)]
3448
IndexFromPack {
35-
/// Display verbose messages and progress information
36-
#[structopt(long, short = "v")]
37-
verbose: bool,
38-
39-
/// Bring up a terminal user interface displaying progress visually
40-
#[structopt(long, conflicts_with("verbose"))]
41-
progress: bool,
42-
43-
/// The progress TUI will stay up even though the work is already completed.
44-
///
45-
/// Use this to be able to read progress messages or additional information visible in the TUI log pane.
46-
#[structopt(long, conflicts_with("verbose"), requires("progress"))]
47-
progress_keep_open: bool,
48-
4949
/// Specify how to iterate the pack, defaults to 'verify'
5050
///
5151
/// Valid values are
@@ -105,20 +105,6 @@ mod options {
105105
#[structopt(long)]
106106
sink_compress: bool,
107107

108-
/// Display verbose messages and progress information
109-
#[structopt(long, short = "v")]
110-
verbose: bool,
111-
112-
/// Bring up a terminal user interface displaying progress visually
113-
#[structopt(long, conflicts_with("verbose"))]
114-
progress: bool,
115-
116-
/// The progress TUI will stay up even though the work is already completed.
117-
///
118-
/// Use this to be able to read progress messages or additional information visible in the TUI log pane.
119-
#[structopt(long, conflicts_with("verbose"), requires("progress"))]
120-
progress_keep_open: bool,
121-
122108
/// The '.pack' or '.idx' file to explode into loose objects
123109
#[structopt(parse(from_os_str))]
124110
pack_path: PathBuf,
@@ -151,14 +137,6 @@ mod options {
151137
)]
152138
algorithm: core::pack::verify::Algorithm,
153139

154-
/// Display verbose messages and progress information
155-
#[structopt(long, short = "v")]
156-
verbose: bool,
157-
158-
/// Bring up a terminal user interface displaying progress visually
159-
#[structopt(long, conflicts_with("verbose"))]
160-
progress: bool,
161-
162140
#[structopt(long, conflicts_with("re-encode"))]
163141
/// Decode and parse tags, commits and trees to validate their correctness beyond hashing correctly.
164142
///
@@ -175,12 +153,6 @@ mod options {
175153
/// owned objects, causing plenty of allocation to occour.
176154
re_encode: bool,
177155

178-
/// The progress TUI will stay up even though the work is already completed.
179-
///
180-
/// Use this to be able to read progress messages or additional information visible in the TUI log pane.
181-
#[structopt(long, conflicts_with("verbose"), requires("progress"))]
182-
progress_keep_open: bool,
183-
184156
/// The '.pack' or '.idx' file whose checksum to validate.
185157
#[structopt(parse(from_os_str))]
186158
path: PathBuf,
@@ -292,14 +264,15 @@ fn prepare_and_run<T: Send + 'static>(
292264
pub fn main() -> Result<()> {
293265
let args = Args::from_args();
294266
let thread_limit = args.threads;
267+
let verbose = args.verbose;
268+
let progress = args.progress;
269+
let progress_keep_open = args.progress_keep_open;
270+
295271
match args.cmd {
296272
Subcommands::IndexFromPack {
297-
verbose,
298273
iteration_mode,
299274
pack_path,
300275
directory,
301-
progress,
302-
progress_keep_open,
303276
} => prepare_and_run(
304277
"index-from-pack",
305278
verbose,
@@ -318,10 +291,7 @@ pub fn main() -> Result<()> {
318291
},
319292
),
320293
Subcommands::PackExplode {
321-
verbose,
322294
check,
323-
progress,
324-
progress_keep_open,
325295
sink_compress,
326296
delete_pack,
327297
pack_path,
@@ -350,12 +320,9 @@ pub fn main() -> Result<()> {
350320
Subcommands::PackVerify {
351321
path,
352322
algorithm,
353-
verbose,
354-
progress,
355323
format,
356324
decode,
357325
re_encode,
358-
progress_keep_open,
359326
statistics,
360327
} => prepare_and_run(
361328
"pack-verify",

tasks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
* [x] for pretty mode
3434
* [x] allow interrupting the resolution phase too
3535
* [x] fix typo :D - thanks IJ for confusing me
36-
* [ ] move --verbose, --progress and --progress-keep-open to the top-level
36+
* [x] move --verbose, --progress and --progress-keep-open to the top-level
3737
* [ ] unit tests for bundle index write
3838
* [ ] journey test for command-line capabilities
3939
* [ ] nicer errors with descriptive messages

0 commit comments

Comments
 (0)