Skip to content

Commit 5cfdb2a

Browse files
committed
Better descriptions for flags and options
1 parent a64ad56 commit 5cfdb2a

File tree

2 files changed

+64
-68
lines changed

2 files changed

+64
-68
lines changed

src/info.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub struct Info {
3737
bold_enabled: bool,
3838
no_color_blocks: bool,
3939
custom_image: Option<DynamicImage>,
40-
image_backend: Option<Box<dyn ImageBackend>>
40+
image_backend: Option<Box<dyn ImageBackend>>,
4141
}
4242

4343
impl std::fmt::Display for Info {

src/main.rs

+63-67
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ fn main() -> Result<()> {
114114
.about(crate_description!())
115115
.arg(
116116
Arg::with_name("directory")
117+
.help("Run as if git was started in <directory> instead of the current working directory.")
117118
.short("d")
118119
.long("dir")
119120
.takes_value(true)
@@ -131,40 +132,32 @@ fn main() -> Result<()> {
131132
.collect::<Vec<&str>>(),
132133
)
133134
.case_insensitive(true)
134-
.help("Overrides showing the dominant language ascii logo."),
135+
.help("Which language's ascii art to print."),
135136
)
136137
.arg(
137-
Arg::with_name("disable-field")
138-
.short("f")
139-
.long("disable-field")
138+
Arg::with_name("disable-fields")
139+
.long("disable-fields")
140+
.short("D")
140141
.multiple(true)
141142
.takes_value(true)
142143
.case_insensitive(true)
143-
.default_value("")
144-
.hide_default_value(true)
145-
.help(&format!(
146-
"Disable fields to show\nPossible values: {:?}",
144+
.help("Allows you to disable an info line from appearing in the output.")
145+
.possible_values(
147146
&InfoFields::iter()
148147
.take(InfoFields::count() - 1)
149148
.map(|field| field.into())
150149
.collect::<Vec<&str>>()
151150
.as_slice()
152-
)),
151+
),
153152
)
154153
.arg(
155-
Arg::with_name("colors")
154+
Arg::with_name("ascii-colors")
156155
.short("c")
157-
.long("colors")
156+
.long("ascii-colors")
158157
.multiple(true)
159158
.takes_value(true)
160-
.possible_values(&[
161-
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14",
162-
"15",
163-
])
164-
.hide_possible_values(true)
165159
.help(&format!(
166-
"Specifies a preferred color set. Unspecified colors will remain as default.
167-
Possible values: [{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}]",
160+
"Colors to print the ascii art. Possible values: [{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}]",
168161
"0".black(),
169162
"1".red(),
170163
"2".green(),
@@ -182,13 +175,12 @@ Possible values: [{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}]",
182175
"14".bright_cyan(),
183176
"15".bright_white(),
184177
)),
185-
)
186-
.arg(
187-
Arg::with_name("no-bold")
188-
.short("b")
189-
.long("no-bold")
190-
.help("Turns off bold formatting for the logo and all labels"),
191-
)
178+
)
179+
.arg(
180+
Arg::with_name("no-bold")
181+
.long("no-bold")
182+
.help("Turns off bold formatting."),
183+
)
192184
.arg(
193185
Arg::with_name("languages")
194186
.short("l")
@@ -200,24 +192,22 @@ Possible values: [{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}]",
200192
.short("i")
201193
.long("image")
202194
.takes_value(true)
203-
.help("Sets a custom image to use instead of the ascii logo"),
195+
.help("Which image to use. Possible values: [/path/to/img]"),
204196
)
205197
.arg(
206198
Arg::with_name("image-backend")
207199
.long("image-backend")
208200
.takes_value(true)
209201
.possible_values(&possible_backends)
210-
.help("Overrides image backend detection"),
202+
.help("Which image backend to use."),
211203
)
212204
.arg(
213-
Arg::with_name("no-merges")
214-
.short("m")
215-
.long("no-merges")
216-
.help("Prevents merge commits from being counted"),
205+
Arg::with_name("no-merges-commits")
206+
.long("no-merge-commits")
207+
.help("Ignore merge commits"),
217208
)
218209
.arg(
219210
Arg::with_name("no-color-blocks")
220-
.short("k")
221211
.long("no-color-blocks")
222212
.help("Hide the color blocks"),
223213
)
@@ -226,7 +216,8 @@ Possible values: [{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}]",
226216
.short("A")
227217
.long("authors-number")
228218
.takes_value(true)
229-
.help("Defines the number of authors to be shown"),
219+
.default_value("3")
220+
.help("Number of authors to be shown."),
230221
)
231222
.get_matches();
232223

@@ -250,34 +241,36 @@ Possible values: [{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}]",
250241
..Default::default()
251242
};
252243

253-
matches
254-
.values_of("disable-field")
255-
.unwrap()
256-
.map(String::from)
257-
.for_each(|field: String| {
258-
let item = InfoFields::from_str(field.to_lowercase().as_str())
259-
.unwrap_or(InfoFields::UnrecognizedField);
260-
261-
match item {
262-
InfoFields::GitInfo => disable_fields.git_info = true,
263-
InfoFields::Project => disable_fields.project = true,
264-
InfoFields::HEAD => disable_fields.head = true,
265-
InfoFields::Version => disable_fields.version = true,
266-
InfoFields::Created => disable_fields.created = true,
267-
InfoFields::Languages => disable_fields.languages = true,
268-
InfoFields::Authors => disable_fields.authors = true,
269-
InfoFields::LastChange => disable_fields.last_change = true,
270-
InfoFields::Repo => disable_fields.repo = true,
271-
InfoFields::Pending => disable_fields.pending = true,
272-
InfoFields::Commits => disable_fields.commits = true,
273-
InfoFields::LinesOfCode => disable_fields.lines_of_code = true,
274-
InfoFields::Size => disable_fields.size = true,
275-
InfoFields::License => disable_fields.license = true,
276-
_ => (),
277-
}
278-
});
279-
280-
let custom_colors: Vec<String> = if let Some(values) = matches.values_of("colors") {
244+
let fields_to_hide: Vec<String> = if let Some(values) = matches.values_of("disable-fields") {
245+
values.map(String::from).collect()
246+
} else {
247+
Vec::new()
248+
};
249+
250+
for field in fields_to_hide.iter() {
251+
let item = InfoFields::from_str(field.to_lowercase().as_str())
252+
.unwrap_or(InfoFields::UnrecognizedField);
253+
254+
match item {
255+
InfoFields::GitInfo => disable_fields.git_info = true,
256+
InfoFields::Project => disable_fields.project = true,
257+
InfoFields::HEAD => disable_fields.head = true,
258+
InfoFields::Version => disable_fields.version = true,
259+
InfoFields::Created => disable_fields.created = true,
260+
InfoFields::Languages => disable_fields.languages = true,
261+
InfoFields::Authors => disable_fields.authors = true,
262+
InfoFields::LastChange => disable_fields.last_change = true,
263+
InfoFields::Repo => disable_fields.repo = true,
264+
InfoFields::Pending => disable_fields.pending = true,
265+
InfoFields::Commits => disable_fields.commits = true,
266+
InfoFields::LinesOfCode => disable_fields.lines_of_code = true,
267+
InfoFields::Size => disable_fields.size = true,
268+
InfoFields::License => disable_fields.license = true,
269+
_ => (),
270+
}
271+
}
272+
273+
let custom_colors: Vec<String> = if let Some(values) = matches.values_of("ascii-colors") {
281274
values.map(String::from).collect()
282275
} else {
283276
Vec::new()
@@ -293,11 +286,14 @@ Possible values: [{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}]",
293286
let image_backend = if custom_image.is_some() {
294287
if let Some(backend_name) = matches.value_of("image-backend") {
295288
#[cfg(target_os = "linux")]
296-
let backend = Some(match backend_name {
297-
"kitty" => Box::new(image_backends::kitty::KittyBackend::new()) as Box<dyn ImageBackend>,
298-
"sixel" => Box::new(image_backends::sixel::SixelBackend::new()) as Box<dyn ImageBackend>,
299-
_ => unreachable!()
300-
});
289+
let backend =
290+
Some(match backend_name {
291+
"kitty" => Box::new(image_backends::kitty::KittyBackend::new())
292+
as Box<dyn ImageBackend>,
293+
"sixel" => Box::new(image_backends::sixel::SixelBackend::new())
294+
as Box<dyn ImageBackend>,
295+
_ => unreachable!(),
296+
});
301297
#[cfg(not(target_os = "linux"))]
302298
let backend = None;
303299
backend
@@ -308,7 +304,7 @@ Possible values: [{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}]",
308304
None
309305
};
310306

311-
let no_merges = matches.is_present("no-merges");
307+
let no_merges = matches.is_present("no-merges-commits");
312308

313309
let color_blocks_flag = matches.is_present("no-color-blocks");
314310

0 commit comments

Comments
 (0)