@@ -6,161 +6,7 @@ use std::io::{stderr, stdout, Write};
6
6
use gitoxide_core:: pack:: verify;
7
7
use options:: * ;
8
8
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;
164
10
165
11
use crate :: shared:: ProgressRange ;
166
12
0 commit comments