@@ -8,13 +8,26 @@ use clap::{Parser, Subcommand};
8
8
#[ derive( Parser , Debug ) ]
9
9
#[ clap( version, about, long_about = None ) ]
10
10
pub struct Args {
11
+ /// Specifies how the program will read the git history.
11
12
#[ clap( subcommand) ]
12
13
input_method : InputMethod ,
13
14
14
15
/// Always show the entire output.
15
16
#[ clap( short = 'v' , long = "verbose" ) ]
16
17
is_verbose : bool ,
17
18
19
+ /// Filter loc for certain file extension (e.g. `--file-extension cpp`). ORs if specified multiple times.
20
+ #[ clap( short, long) ]
21
+ file_extension : Vec < String > ,
22
+
23
+ /// The time which may pass between two commits that still counts as working.
24
+ #[ clap( short, long, default_value_t = 3 ) ]
25
+ duration : u32 ,
26
+
27
+ /// An output file for the commits per day in CSV format.
28
+ #[ clap( short, long) ]
29
+ output : Option < PathBuf > ,
30
+
18
31
/// Filter for certain author names. ORs if specified multiple times.
19
32
#[ clap( short, long) ]
20
33
author_contains : Vec < String > ,
@@ -26,64 +39,57 @@ pub struct Args {
26
39
/// Filter for certain author emails. ORs if specified multiple times.
27
40
#[ clap( short, long) ]
28
41
email_contains : Vec < String > ,
42
+
29
43
/// Filter for certain author emails. ORs if specified multiple times.
30
44
#[ clap( long) ]
31
45
email_equals : Vec < String > ,
32
46
33
47
/// Filter for certain commit hashes. ORs if specified multiple times.
34
48
#[ clap( short, long) ]
35
49
commit_contains : Vec < String > ,
50
+
36
51
/// Filter for certain commit hashes. ORs if specified multiple times.
37
52
#[ clap( long) ]
38
53
commit_equals : Vec < String > ,
39
54
40
- /// Filter loc for certain file extension (e.g. `--file-extension cpp`). ORs if specified multiple times.
41
- #[ clap( short, long) ]
42
- file_extension : Vec < String > ,
43
-
44
55
/// Filter for certain commit messages. ORs if specified multiple times.
45
56
#[ clap( short, long) ]
46
57
message_contains : Vec < String > ,
58
+
47
59
/// Filter for certain commit messages. ORs if specified multiple times.
48
60
#[ clap( long) ]
49
61
message_equals : Vec < String > ,
62
+
50
63
/// Filter for certain commit messages. ORs if specified multiple times.
51
64
#[ clap( short = 'l' , long) ]
52
65
message_starts_with : Vec < String > ,
53
-
54
- /// The time which may pass between two commits that still counts as working.
55
- #[ clap( short, long, default_value_t = 3 ) ]
56
- duration : u32 ,
57
-
58
- /// An output file for the commits per day in CSV format.
59
- #[ clap( short, long) ]
60
- output : Option < PathBuf > ,
61
66
}
62
67
63
68
impl Args {
64
- /// Get the input method specified by the user.
69
+ /// Gets the input method specified by the user.
65
70
#[ must_use]
66
71
pub fn input_method ( & self ) -> & InputMethod {
67
72
& self . input_method
68
73
}
69
74
70
- /// Get the configured verbosity level of the program.
75
+ /// Gets the configured verbosity level of the program.
71
76
#[ must_use]
72
77
pub fn is_verbose ( & self ) -> bool {
73
78
self . is_verbose
74
79
}
75
80
76
- /// Get the maximum duration between two commits considered spent working.
81
+ /// Gets the maximum duration between two commits considered spent working.
77
82
#[ must_use]
78
83
pub fn duration ( & self ) -> u32 {
79
84
self . duration
80
85
}
81
86
82
- /// Takes the output path, specified by the user, out of `Args`.
87
+ /// Moves the output path specified by the user out of `Args` by calling
88
+ /// `Option::take`.
83
89
///
84
90
/// This method moves the specified path to the intended output file out of
85
- /// this struct. This should therefore only be called once, but saves an
86
- /// unnecessary clone.
91
+ /// this struct. This should, hence, be called just once but prevents an
92
+ /// obsolete clone.
87
93
#[ must_use]
88
94
pub fn take_output ( & mut self ) -> Option < PathBuf > {
89
95
self . output . take ( )
@@ -157,7 +163,7 @@ impl InputMethod {
157
163
158
164
/// The revealed filter creteria.
159
165
///
160
- /// This data structure allows to filter the input commits by certain creteria .
166
+ /// This data structure allows to filter the input commits by certain criteria .
161
167
#[ derive( Debug , Default ) ]
162
168
pub struct Filter < ' a > {
163
169
/// A set of substrings to be contained by some authors' names.
@@ -524,7 +530,7 @@ impl LocDiff {
524
530
& self . file
525
531
}
526
532
527
- /// Calculate the LOC diff.
533
+ /// Calculates the LOC diff.
528
534
pub fn loc ( & self ) -> i64 {
529
535
if self . added . is_none ( ) && self . removed . is_none ( ) {
530
536
0
@@ -533,7 +539,7 @@ impl LocDiff {
533
539
}
534
540
}
535
541
536
- /// Extract the LOC diff information from the given line.
542
+ /// Extracts the LOC diff information from the given line.
537
543
pub fn parse ( loc : & str ) -> Result < Self , LocParseError > {
538
544
let ( added, remainder) = loc
539
545
. split_once ( '\t' )
0 commit comments