Skip to content

Commit b3021c5

Browse files
committed
Fix documentation and field order
This adds/improves documentation in `Args` and fixes the documentation in other places. Also this orders the fields of `Args` so that the `Filter` related fields come last, since they are the least important, and take up a lot of space.
1 parent 69c563c commit b3021c5

File tree

1 file changed

+26
-21
lines changed

1 file changed

+26
-21
lines changed

src/lib.rs

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,27 @@ use clap::{Parser, Subcommand};
88
#[derive(Parser, Debug)]
99
#[clap(version, about, long_about = None)]
1010
pub struct Args {
11+
/// Specifies how the program will read the git history.
1112
#[clap(subcommand)]
1213
input_method: InputMethod,
1314

1415
/// Always show the entire output.
1516
#[clap(short = 'v', long = "verbose")]
1617
is_verbose: bool,
1718

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+
1832
/// Filter for certain author names. ORs if specified multiple times.
1933
#[clap(short, long)]
2034
author_contains: Vec<String>,
@@ -26,65 +40,56 @@ pub struct Args {
2640
/// Filter for certain author emails. ORs if specified multiple times.
2741
#[clap(short, long)]
2842
email_contains: Vec<String>,
43+
2944
/// Filter for certain author emails. ORs if specified multiple times.
3045
#[clap(long)]
3146
email_equals: Vec<String>,
3247

3348
/// Filter for certain commit hashes. ORs if specified multiple times.
3449
#[clap(short, long)]
3550
commit_contains: Vec<String>,
51+
3652
/// Filter for certain commit hashes. ORs if specified multiple times.
3753
#[clap(long)]
3854
commit_equals: Vec<String>,
3955

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-
4556
/// Filter for certain commit messages. ORs if specified multiple times.
4657
#[clap(short, long)]
4758
message_contains: Vec<String>,
59+
4860
/// Filter for certain commit messages. ORs if specified multiple times.
4961
#[clap(long)]
5062
message_equals: Vec<String>,
63+
5164
/// Filter for certain commit messages. ORs if specified multiple times.
5265
#[clap(short = 'l', long)]
5366
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>,
6267
}
6368

6469
impl Args {
65-
/// Get the input method specified by the user.
70+
/// Gets the input method specified by the user.
6671
#[must_use]
6772
pub fn input_method(&self) -> &InputMethod {
6873
&self.input_method
6974
}
7075

71-
/// Get the configured verbosity level of the program.
76+
/// Gets the configured verbosity level of the program.
7277
#[must_use]
7378
pub fn is_verbose(&self) -> bool {
7479
self.is_verbose
7580
}
7681

77-
/// Get the maximum duration between two commits considered spent working.
82+
/// Gets the maximum duration between two commits considered spent working.
7883
#[must_use]
7984
pub fn duration(&self) -> u32 {
8085
self.duration
8186
}
8287

83-
/// Takes the output path, specified by the user, out of `Args`.
88+
/// Moves the output path specified by the user out of `Args`
8489
///
8590
/// 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.
8893
#[must_use]
8994
pub fn take_output(&mut self) -> Option<PathBuf> {
9095
self.output.take()
@@ -525,7 +530,7 @@ impl LocDiff {
525530
&self.file
526531
}
527532

528-
/// Calculate the LOC diff.
533+
/// Calculates the LOC diff.
529534
pub fn loc(&self) -> i64 {
530535
if self.added.is_none() && self.removed.is_none() {
531536
0
@@ -534,7 +539,7 @@ impl LocDiff {
534539
}
535540
}
536541

537-
/// Extract the LOC diff information from the given line.
542+
/// Extracts the LOC diff information from the given line.
538543
pub fn parse(loc: &str) -> Result<Self, LocParseError> {
539544
let (added, remainder) = loc
540545
.split_once('\t')

0 commit comments

Comments
 (0)