Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uniq: move help strings to markdown file #4681

Merged
merged 1 commit into from
Mar 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions src/uu/uniq/src/uniq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,11 @@ use std::path::Path;
use std::str::FromStr;
use uucore::display::Quotable;
use uucore::error::{FromIo, UResult, USimpleError, UUsageError};
use uucore::format_usage;
use uucore::{format_usage, help_about, help_section, help_usage};

const ABOUT: &str = "Report or omit repeated lines.";
const USAGE: &str = "{} [OPTION]... [INPUT [OUTPUT]]...";
const LONG_USAGE: &str = "\
Filter adjacent matching lines from INPUT (or standard input),\n\
writing to OUTPUT (or standard output).\n\n\
Note: 'uniq' does not detect repeated lines unless they are adjacent.\n\
You may want to sort the input first, or use 'sort -u' without 'uniq'.";
const ABOUT: &str = help_about!("uniq.md");
const USAGE: &str = help_usage!("uniq.md");
const AFTER_HELP: &str = help_section!("after help", "uniq.md");

pub mod options {
pub static ALL_REPEATED: &str = "all-repeated";
Expand Down Expand Up @@ -247,7 +243,7 @@ fn opt_parsed<T: FromStr>(opt_name: &str, matches: &ArgMatches) -> UResult<Optio

#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let matches = uu_app().after_help(LONG_USAGE).try_get_matches_from(args)?;
let matches = uu_app().after_help(AFTER_HELP).try_get_matches_from(args)?;

let files: Vec<String> = matches
.get_many::<String>(ARG_FILES)
Expand Down
15 changes: 15 additions & 0 deletions src/uu/uniq/uniq.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# uniq

```
uniq [OPTION]... [INPUT [OUTPUT]]...
```

Report or omit repeated lines.

## After help

Filter adjacent matching lines from `INPUT` (or standard input),
writing to `OUTPUT` (or standard output).

Note: `uniq` does not detect repeated lines unless they are adjacent.
You may want to sort the input first, or use `sort -u` without `uniq`.