Skip to content

Commit da664ec

Browse files
authored
Merge pull request #10107 from ChrisDryden/pr-omit-pagination
pr: add -T/--omit-pagination option
2 parents a1de3ed + 25d5051 commit da664ec

3 files changed

Lines changed: 25 additions & 1 deletion

File tree

src/uu/pr/locales/en-US.ftl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ pr-help-omit-header =
3030
Write neither the five-line identifying header nor the five-line
3131
trailer usually supplied for each page. Quit writing after the last line
3232
of each file without spacing to the end of the page.
33+
pr-help-omit-pagination =
34+
omit page headers and trailers, eliminate any pagination
35+
by form feeds set in input files
3336
pr-help-page-length =
3437
Override the 66-line default (default number of lines of text 56,
3538
and with -F 63) and reset the page length to lines. If lines is not

src/uu/pr/src/pr.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ mod options {
4242
pub const FIRST_LINE_NUMBER: &str = "first-line-number";
4343
pub const PAGES: &str = "pages";
4444
pub const OMIT_HEADER: &str = "omit-header";
45+
pub const OMIT_PAGINATION: &str = "omit-pagination";
4546
pub const PAGE_LENGTH: &str = "length";
4647
pub const NO_FILE_WARNINGS: &str = "no-file-warnings";
4748
pub const FORM_FEED: &str = "form-feed";
@@ -215,6 +216,13 @@ pub fn uu_app() -> Command {
215216
.help(translate!("pr-help-omit-header"))
216217
.action(ArgAction::SetTrue),
217218
)
219+
.arg(
220+
Arg::new(options::OMIT_PAGINATION)
221+
.short('T')
222+
.long(options::OMIT_PAGINATION)
223+
.help(translate!("pr-help-omit-pagination"))
224+
.action(ArgAction::SetTrue),
225+
)
218226
.arg(
219227
Arg::new(options::PAGE_LENGTH)
220228
.short('l')
@@ -633,7 +641,9 @@ fn build_options(
633641

634642
let page_length_le_ht = page_length < (HEADER_LINES_PER_PAGE + TRAILER_LINES_PER_PAGE);
635643

636-
let display_header_and_trailer = !page_length_le_ht && !matches.get_flag(options::OMIT_HEADER);
644+
let display_header_and_trailer = !page_length_le_ht
645+
&& !matches.get_flag(options::OMIT_HEADER)
646+
&& !matches.get_flag(options::OMIT_PAGINATION);
637647

638648
let content_lines_per_page = if page_length_le_ht {
639649
page_length

tests/by-util/test_pr.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,3 +641,14 @@ fn test_separator_options_default_values() {
641641
.pipe_in("a\nb\n")
642642
.succeeds();
643643
}
644+
645+
#[test]
646+
fn test_omit_pagination_option() {
647+
// -T/--omit-pagination omits headers/trailers and eliminates form feeds
648+
// TODO: verify output matches GNU pr behavior (form feed elimination)
649+
new_ucmd!().args(&["-T"]).pipe_in("a\nb\n").succeeds();
650+
new_ucmd!()
651+
.args(&["--omit-pagination"])
652+
.pipe_in("a\nb\n")
653+
.succeeds();
654+
}

0 commit comments

Comments
 (0)