Skip to content

Commit 4f212a6

Browse files
committed
fix options
1 parent 7649214 commit 4f212a6

File tree

1 file changed

+57
-51
lines changed

1 file changed

+57
-51
lines changed

src/uu/more/src/more.rs

Lines changed: 57 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,15 @@ pub mod options {
4747
const MULTI_FILE_TOP_PROMPT: &str = "\r::::::::::::::\n\r{}\n\r::::::::::::::\n";
4848

4949
struct Options {
50+
silent: bool,
51+
_logical: bool,
52+
_no_pause: bool,
53+
print_over: bool,
5054
clean_print: bool,
51-
from_line: usize,
55+
squeeze: bool,
5256
lines: Option<u16>,
57+
from_line: usize,
5358
pattern: Option<String>,
54-
print_over: bool,
55-
silent: bool,
56-
squeeze: bool,
5759
}
5860

5961
impl Options {
@@ -76,13 +78,15 @@ impl Options {
7678
.get_one::<String>(options::PATTERN)
7779
.map(|s| s.to_owned());
7880
Self {
81+
silent: matches.get_flag(options::SILENT),
82+
_logical: matches.get_flag(options::LOGICAL),
83+
_no_pause: matches.get_flag(options::NO_PAUSE),
84+
print_over: matches.get_flag(options::PRINT_OVER),
7985
clean_print: matches.get_flag(options::CLEAN_PRINT),
80-
from_line,
86+
squeeze: matches.get_flag(options::SQUEEZE),
8187
lines,
88+
from_line,
8289
pattern,
83-
print_over: matches.get_flag(options::PRINT_OVER),
84-
silent: matches.get_flag(options::SILENT),
85-
squeeze: matches.get_flag(options::SQUEEZE),
8690
}
8791
}
8892
}
@@ -242,40 +246,62 @@ pub fn uu_app() -> Command {
242246
.override_usage(format_usage(USAGE))
243247
.version(uucore::crate_version!())
244248
.infer_long_args(true)
245-
.arg(
246-
Arg::new(options::PRINT_OVER)
247-
.short('c')
248-
.long(options::PRINT_OVER)
249-
.help("Do not scroll, display text and clean line ends")
250-
.action(ArgAction::SetTrue),
251-
)
252249
.arg(
253250
Arg::new(options::SILENT)
254251
.short('d')
255252
.long(options::SILENT)
256-
.help("Display help instead of ringing bell")
257-
.action(ArgAction::SetTrue),
253+
.action(ArgAction::SetTrue)
254+
.help("Display help instead of ringing bell when an illegal key is pressed."),
258255
)
259256
.arg(
260-
Arg::new(options::CLEAN_PRINT)
257+
Arg::new(options::LOGICAL)
258+
.short('f')
259+
.long(options::LOGICAL)
260+
.action(ArgAction::SetTrue)
261+
.help("Do not pause after form feed"),
262+
)
263+
.arg(
264+
Arg::new(options::NO_PAUSE)
265+
.short('l')
266+
.long(options::NO_PAUSE)
267+
.action(ArgAction::SetTrue)
268+
.help("Count logical lines rather than screen lines"),
269+
)
270+
.arg(
271+
Arg::new(options::PRINT_OVER)
261272
.short('p')
273+
.long(options::PRINT_OVER)
274+
.action(ArgAction::SetTrue)
275+
.help("Do not scroll, clean screen and display text"),
276+
)
277+
.arg(
278+
Arg::new(options::CLEAN_PRINT)
279+
.short('c')
262280
.long(options::CLEAN_PRINT)
263-
.help("Do not scroll, clean screen and display text")
264-
.action(ArgAction::SetTrue),
281+
.action(ArgAction::SetTrue)
282+
.help("Do not scroll, display text and clean line ends"),
265283
)
266284
.arg(
267285
Arg::new(options::SQUEEZE)
268286
.short('s')
269287
.long(options::SQUEEZE)
270-
.help("Squeeze multiple blank lines into one")
271-
.action(ArgAction::SetTrue),
288+
.action(ArgAction::SetTrue)
289+
.help("Squeeze multiple blank lines into one"),
272290
)
273291
.arg(
274292
Arg::new(options::PLAIN)
275293
.short('u')
276294
.long(options::PLAIN)
277295
.action(ArgAction::SetTrue)
278-
.hide(true),
296+
.hide(true)
297+
.help("Suppress underlining"),
298+
)
299+
.arg(
300+
Arg::new(options::NUMBER)
301+
.long(options::NUMBER)
302+
.num_args(1)
303+
.value_parser(value_parser!(u16).range(0..))
304+
.help("same as --lines option argument"),
279305
)
280306
.arg(
281307
Arg::new(options::PATTERN)
@@ -284,7 +310,7 @@ pub fn uu_app() -> Command {
284310
.allow_hyphen_values(true)
285311
.required(false)
286312
.value_name("pattern")
287-
.help("Display file beginning from pattern match"),
313+
.help("The string to be searched in each file before starting to display it"),
288314
)
289315
.arg(
290316
Arg::new(options::FROM_LINE)
@@ -293,7 +319,7 @@ pub fn uu_app() -> Command {
293319
.num_args(1)
294320
.value_name("number")
295321
.value_parser(value_parser!(usize))
296-
.help("Display file beginning from line number"),
322+
.help("Start displaying each file at line number"),
297323
)
298324
.arg(
299325
Arg::new(options::LINES)
@@ -304,28 +330,6 @@ pub fn uu_app() -> Command {
304330
.value_parser(value_parser!(u16).range(0..))
305331
.help("The number of lines per screen full"),
306332
)
307-
.arg(
308-
Arg::new(options::NUMBER)
309-
.long(options::NUMBER)
310-
.num_args(1)
311-
.value_parser(value_parser!(u16).range(0..))
312-
.help("Same as --lines"),
313-
)
314-
// The commented arguments below are unimplemented:
315-
/*
316-
.arg(
317-
Arg::new(options::LOGICAL)
318-
.short('f')
319-
.long(options::LOGICAL)
320-
.help("Count logical rather than screen lines"),
321-
)
322-
.arg(
323-
Arg::new(options::NO_PAUSE)
324-
.short('l')
325-
.long(options::NO_PAUSE)
326-
.help("Suppress pause after form feed"),
327-
)
328-
*/
329333
.arg(
330334
Arg::new(options::FILES)
331335
.required(false)
@@ -784,13 +788,15 @@ mod tests {
784788
Self {
785789
content: content.to_string(),
786790
options: Options {
791+
silent: false,
792+
_logical: false,
793+
_no_pause: false,
794+
print_over: false,
787795
clean_print: false,
788-
from_line: 0,
796+
squeeze: false,
789797
lines: None,
798+
from_line: 0,
790799
pattern: None,
791-
print_over: false,
792-
silent: false,
793-
squeeze: false,
794800
},
795801
rows: 24,
796802
next_file: None,

0 commit comments

Comments
 (0)