Skip to content

Commit f90b92f

Browse files
committed
refactor
1 parent 161e7df commit f90b92f

File tree

2 files changed

+154
-155
lines changed

2 files changed

+154
-155
lines changed

Diff for: src/plumbing/pretty.rs renamed to src/plumbing/pretty/mod.rs

+1-155
Original file line numberDiff line numberDiff line change
@@ -6,161 +6,7 @@ use std::io::{stderr, stdout, Write};
66
use gitoxide_core::pack::verify;
77
use options::*;
88

9-
mod options {
10-
use clap::{AppSettings, Clap};
11-
use gitoxide_core as core;
12-
use std::path::PathBuf;
13-
14-
#[derive(Debug, Clap)]
15-
#[clap(name = "gix-plumbing", about = "The git underworld", version = clap::crate_version!())]
16-
#[clap(setting = AppSettings::SubcommandRequired)]
17-
#[clap(setting = AppSettings::ColoredHelp)]
18-
pub struct Args {
19-
#[clap(long, short = "t")]
20-
/// The amount of threads to use for some operations.
21-
///
22-
/// If unset, or the value is 0, there is no limit and all logical cores can be used.
23-
pub threads: Option<usize>,
24-
25-
/// Display verbose messages and progress information
26-
#[clap(long, short = "v")]
27-
pub verbose: bool,
28-
29-
/// Bring up a terminal user interface displaying progress visually
30-
#[clap(long, conflicts_with("verbose"))]
31-
pub progress: bool,
32-
33-
/// The progress TUI will stay up even though the work is already completed.
34-
///
35-
/// Use this to be able to read progress messages or additional information visible in the TUI log pane.
36-
#[clap(long, conflicts_with("verbose"), requires("progress"))]
37-
pub progress_keep_open: bool,
38-
39-
/// Determine the format to use when outputting statistics.
40-
#[clap(
41-
long,
42-
short = "f",
43-
default_value = "human",
44-
possible_values(core::OutputFormat::variants())
45-
)]
46-
pub format: core::OutputFormat,
47-
48-
#[clap(subcommand)]
49-
pub cmd: Subcommands,
50-
}
51-
52-
#[derive(Debug, Clap)]
53-
pub enum Subcommands {
54-
/// Create an index from a packfile.
55-
///
56-
/// This command can also be used to stream packs to standard input or to repair partial packs.
57-
#[clap(setting = AppSettings::ColoredHelp)]
58-
#[clap(setting = AppSettings::DisableVersion)]
59-
PackIndexFromData {
60-
/// Specify how to iterate the pack, defaults to 'verify'
61-
///
62-
/// Valid values are
63-
///
64-
/// **as-is** do not do anything and expect the pack file to be valid as per the trailing hash,
65-
/// **verify** the input ourselves and validate that it matches with the hash provided in the pack,
66-
/// **restore** hash the input ourselves and ignore failing entries, instead finish the pack with the hash we computed
67-
#[clap(
68-
long,
69-
short = "i",
70-
default_value = "verify",
71-
possible_values(core::pack::index::IterationMode::variants())
72-
)]
73-
iteration_mode: core::pack::index::IterationMode,
74-
75-
/// Path to the pack file to read (with .pack extension).
76-
///
77-
/// If unset, the pack file is expected on stdin.
78-
#[clap(long, short = "p")]
79-
pack_path: Option<PathBuf>,
80-
81-
/// The folder into which to place the pack and the generated index file
82-
///
83-
/// If unset, only informational output will be provided to standard output.
84-
#[clap(parse(from_os_str))]
85-
directory: Option<PathBuf>,
86-
},
87-
/// Verify the integrity of a pack or index file
88-
#[clap(setting = AppSettings::ColoredHelp)]
89-
#[clap(setting = AppSettings::DisableVersion)]
90-
PackExplode {
91-
#[clap(long)]
92-
/// Read written objects back and assert they match their source. Fail the operation otherwise.
93-
///
94-
/// Only relevant if an object directory is set.
95-
verify: bool,
96-
97-
/// delete the pack and index file after the operation is successful
98-
#[clap(long)]
99-
delete_pack: bool,
100-
101-
/// The amount of checks to run
102-
#[clap(
103-
long,
104-
short = "c",
105-
default_value = "all",
106-
possible_values(core::pack::explode::SafetyCheck::variants())
107-
)]
108-
check: core::pack::explode::SafetyCheck,
109-
110-
/// Compress bytes even when using the sink, i.e. no object directory is specified
111-
///
112-
/// This helps to determine overhead related to compression. If unset, the sink will
113-
/// only create hashes from bytes, which is usually limited by the speed at which input
114-
/// can be obtained.
115-
#[clap(long)]
116-
sink_compress: bool,
117-
118-
/// The '.pack' or '.idx' file to explode into loose objects
119-
#[clap(parse(from_os_str))]
120-
pack_path: PathBuf,
121-
122-
/// The path into which all objects should be written. Commonly '.git/objects'
123-
#[clap(parse(from_os_str))]
124-
object_path: Option<PathBuf>,
125-
},
126-
/// Verify the integrity of a pack or index file
127-
#[clap(setting = AppSettings::ColoredHelp)]
128-
#[clap(setting = AppSettings::DisableVersion)]
129-
PackVerify {
130-
/// output statistical information about the pack
131-
#[clap(long, short = "s")]
132-
statistics: bool,
133-
/// The algorithm used to verify the pack. They differ in costs.
134-
#[clap(
135-
long,
136-
short = "a",
137-
default_value = "less-time",
138-
possible_values(core::pack::verify::Algorithm::variants())
139-
)]
140-
algorithm: core::pack::verify::Algorithm,
141-
142-
#[clap(long, conflicts_with("re-encode"))]
143-
/// Decode and parse tags, commits and trees to validate their correctness beyond hashing correctly.
144-
///
145-
/// Malformed objects should not usually occur, but could be injected on purpose or accident.
146-
/// This will reduce overall performance.
147-
decode: bool,
148-
149-
#[clap(long)]
150-
/// Decode and parse tags, commits and trees to validate their correctness, and re-encode them.
151-
///
152-
/// This flag is primarily to test the implementation of encoding, and requires to decode the object first.
153-
/// Encoding an object after decoding it should yield exactly the same bytes.
154-
/// This will reduce overall performance even more, as re-encoding requires to transform zero-copy objects into
155-
/// owned objects, causing plenty of allocation to occour.
156-
re_encode: bool,
157-
158-
/// The '.pack' or '.idx' file whose checksum to validate.
159-
#[clap(parse(from_os_str))]
160-
path: PathBuf,
161-
},
162-
}
163-
}
9+
mod options;
16410

16511
use crate::shared::ProgressRange;
16612

Diff for: src/plumbing/pretty/options.rs

+153
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
use clap::{AppSettings, Clap};
2+
use gitoxide_core as core;
3+
use std::path::PathBuf;
4+
5+
#[derive(Debug, Clap)]
6+
#[clap(name = "gix-plumbing", about = "The git underworld", version = clap::crate_version!())]
7+
#[clap(setting = AppSettings::SubcommandRequired)]
8+
#[clap(setting = AppSettings::ColoredHelp)]
9+
pub struct Args {
10+
#[clap(long, short = "t")]
11+
/// The amount of threads to use for some operations.
12+
///
13+
/// If unset, or the value is 0, there is no limit and all logical cores can be used.
14+
pub threads: Option<usize>,
15+
16+
/// Display verbose messages and progress information
17+
#[clap(long, short = "v")]
18+
pub verbose: bool,
19+
20+
/// Bring up a terminal user interface displaying progress visually
21+
#[clap(long, conflicts_with("verbose"))]
22+
pub progress: bool,
23+
24+
/// The progress TUI will stay up even though the work is already completed.
25+
///
26+
/// Use this to be able to read progress messages or additional information visible in the TUI log pane.
27+
#[clap(long, conflicts_with("verbose"), requires("progress"))]
28+
pub progress_keep_open: bool,
29+
30+
/// Determine the format to use when outputting statistics.
31+
#[clap(
32+
long,
33+
short = "f",
34+
default_value = "human",
35+
possible_values(core::OutputFormat::variants())
36+
)]
37+
pub format: core::OutputFormat,
38+
39+
#[clap(subcommand)]
40+
pub cmd: Subcommands,
41+
}
42+
43+
#[derive(Debug, Clap)]
44+
pub enum Subcommands {
45+
/// Create an index from a packfile.
46+
///
47+
/// This command can also be used to stream packs to standard input or to repair partial packs.
48+
#[clap(setting = AppSettings::ColoredHelp)]
49+
#[clap(setting = AppSettings::DisableVersion)]
50+
PackIndexFromData {
51+
/// Specify how to iterate the pack, defaults to 'verify'
52+
///
53+
/// Valid values are
54+
///
55+
/// **as-is** do not do anything and expect the pack file to be valid as per the trailing hash,
56+
/// **verify** the input ourselves and validate that it matches with the hash provided in the pack,
57+
/// **restore** hash the input ourselves and ignore failing entries, instead finish the pack with the hash we computed
58+
#[clap(
59+
long,
60+
short = "i",
61+
default_value = "verify",
62+
possible_values(core::pack::index::IterationMode::variants())
63+
)]
64+
iteration_mode: core::pack::index::IterationMode,
65+
66+
/// Path to the pack file to read (with .pack extension).
67+
///
68+
/// If unset, the pack file is expected on stdin.
69+
#[clap(long, short = "p")]
70+
pack_path: Option<PathBuf>,
71+
72+
/// The folder into which to place the pack and the generated index file
73+
///
74+
/// If unset, only informational output will be provided to standard output.
75+
#[clap(parse(from_os_str))]
76+
directory: Option<PathBuf>,
77+
},
78+
/// Verify the integrity of a pack or index file
79+
#[clap(setting = AppSettings::ColoredHelp)]
80+
#[clap(setting = AppSettings::DisableVersion)]
81+
PackExplode {
82+
#[clap(long)]
83+
/// Read written objects back and assert they match their source. Fail the operation otherwise.
84+
///
85+
/// Only relevant if an object directory is set.
86+
verify: bool,
87+
88+
/// delete the pack and index file after the operation is successful
89+
#[clap(long)]
90+
delete_pack: bool,
91+
92+
/// The amount of checks to run
93+
#[clap(
94+
long,
95+
short = "c",
96+
default_value = "all",
97+
possible_values(core::pack::explode::SafetyCheck::variants())
98+
)]
99+
check: core::pack::explode::SafetyCheck,
100+
101+
/// Compress bytes even when using the sink, i.e. no object directory is specified
102+
///
103+
/// This helps to determine overhead related to compression. If unset, the sink will
104+
/// only create hashes from bytes, which is usually limited by the speed at which input
105+
/// can be obtained.
106+
#[clap(long)]
107+
sink_compress: bool,
108+
109+
/// The '.pack' or '.idx' file to explode into loose objects
110+
#[clap(parse(from_os_str))]
111+
pack_path: PathBuf,
112+
113+
/// The path into which all objects should be written. Commonly '.git/objects'
114+
#[clap(parse(from_os_str))]
115+
object_path: Option<PathBuf>,
116+
},
117+
/// Verify the integrity of a pack or index file
118+
#[clap(setting = AppSettings::ColoredHelp)]
119+
#[clap(setting = AppSettings::DisableVersion)]
120+
PackVerify {
121+
/// output statistical information about the pack
122+
#[clap(long, short = "s")]
123+
statistics: bool,
124+
/// The algorithm used to verify the pack. They differ in costs.
125+
#[clap(
126+
long,
127+
short = "a",
128+
default_value = "less-time",
129+
possible_values(core::pack::verify::Algorithm::variants())
130+
)]
131+
algorithm: core::pack::verify::Algorithm,
132+
133+
#[clap(long, conflicts_with("re-encode"))]
134+
/// Decode and parse tags, commits and trees to validate their correctness beyond hashing correctly.
135+
///
136+
/// Malformed objects should not usually occur, but could be injected on purpose or accident.
137+
/// This will reduce overall performance.
138+
decode: bool,
139+
140+
#[clap(long)]
141+
/// Decode and parse tags, commits and trees to validate their correctness, and re-encode them.
142+
///
143+
/// This flag is primarily to test the implementation of encoding, and requires to decode the object first.
144+
/// Encoding an object after decoding it should yield exactly the same bytes.
145+
/// This will reduce overall performance even more, as re-encoding requires to transform zero-copy objects into
146+
/// owned objects, causing plenty of allocation to occour.
147+
re_encode: bool,
148+
149+
/// The '.pack' or '.idx' file whose checksum to validate.
150+
#[clap(parse(from_os_str))]
151+
path: PathBuf,
152+
},
153+
}

0 commit comments

Comments
 (0)