Skip to content
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
3 changes: 3 additions & 0 deletions src/uu/pr/locales/en-US.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ pr-help-omit-header =
Write neither the five-line identifying header nor the five-line
trailer usually supplied for each page. Quit writing after the last line
of each file without spacing to the end of the page.
pr-help-omit-pagination =
omit page headers and trailers, eliminate any pagination
by form feeds set in input files
pr-help-page-length =
Override the 66-line default (default number of lines of text 56,
and with -F 63) and reset the page length to lines. If lines is not
Expand Down
12 changes: 11 additions & 1 deletion src/uu/pr/src/pr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ mod options {
pub const FIRST_LINE_NUMBER: &str = "first-line-number";
pub const PAGES: &str = "pages";
pub const OMIT_HEADER: &str = "omit-header";
pub const OMIT_PAGINATION: &str = "omit-pagination";
pub const PAGE_LENGTH: &str = "length";
pub const NO_FILE_WARNINGS: &str = "no-file-warnings";
pub const FORM_FEED: &str = "form-feed";
Expand Down Expand Up @@ -215,6 +216,13 @@ pub fn uu_app() -> Command {
.help(translate!("pr-help-omit-header"))
.action(ArgAction::SetTrue),
)
.arg(
Arg::new(options::OMIT_PAGINATION)
.short('T')
.long(options::OMIT_PAGINATION)
.help(translate!("pr-help-omit-pagination"))
.action(ArgAction::SetTrue),
)
.arg(
Arg::new(options::PAGE_LENGTH)
.short('l')
Expand Down Expand Up @@ -633,7 +641,9 @@ fn build_options(

let page_length_le_ht = page_length < (HEADER_LINES_PER_PAGE + TRAILER_LINES_PER_PAGE);

let display_header_and_trailer = !page_length_le_ht && !matches.get_flag(options::OMIT_HEADER);
let display_header_and_trailer = !page_length_le_ht
&& !matches.get_flag(options::OMIT_HEADER)
&& !matches.get_flag(options::OMIT_PAGINATION);

let content_lines_per_page = if page_length_le_ht {
page_length
Expand Down
11 changes: 11 additions & 0 deletions tests/by-util/test_pr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -641,3 +641,14 @@ fn test_separator_options_default_values() {
.pipe_in("a\nb\n")
.succeeds();
}

#[test]
fn test_omit_pagination_option() {
// -T/--omit-pagination omits headers/trailers and eliminates form feeds
// TODO: verify output matches GNU pr behavior (form feed elimination)
new_ucmd!().args(&["-T"]).pipe_in("a\nb\n").succeeds();
new_ucmd!()
.args(&["--omit-pagination"])
.pipe_in("a\nb\n")
.succeeds();
}
Loading