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