Skip to content

Commit

Permalink
Document pager (#36)
Browse files Browse the repository at this point in the history
* Update README

* Clean up FIXME

* Clean up

* Document pager
  • Loading branch information
robenkleene authored Dec 28, 2023
1 parent da19ac0 commit ec953eb
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Rep Grep
# Rep

`rep` is a command-line utility that takes [`grep`](https://en.wikipedia.org/wiki/Grep)-formatted lines via standard input, and performs a find-and-replace on them. By default, it outputs a [`diff`](https://en.wikipedia.org/wiki/Diff)-preview of the changes to standard output, and with a flag it can write the changes to the files in place.

Expand Down Expand Up @@ -28,9 +28,13 @@ The `-n` (`--line-number`) option is required so that `grep` outputs the line nu
cargo install rep-grep
```

## Configuration

The default pager is `less`, the `REP_PAGER` environment variable can be used to override the pager (e.g., `export REP_PAGER=delta` in Bash).

## Help

`rep -h` (or `rep --help`) will list help for all the command-line flags.
`rep -h` (or `rep --help`, `--help` provides slightly longer explanations of some options) will list help for all the command-line flags.

## Acknowledgements

Expand Down
2 changes: 1 addition & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use structopt::{clap::AppSettings, StructOpt};
)]
pub(crate) struct Options {
#[structopt(short = "w", long = "write")]
///
///
/** Write the output to files directly (instead of outputting a patch)
If this flag is not present, and a patch is output, then the default pager is `less`. The
Expand Down
1 change: 0 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ mod edit;
mod patcher;
mod writer;
mod output;
// FIXME: Look at `pub(crate)` calls are all these necessary?
pub(crate) mod replacer;
pub(crate) mod utils;
mod less;
Expand Down
2 changes: 0 additions & 2 deletions src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ impl OutputType {
let pager_path = PathBuf::from(pager_name);

let is_less = pager_path.file_stem() == Some(&OsString::from("less"));
// FIXME: When return fails, `quit_if_one_screen = true`, `replace_arguments_to_less = true`, `is_less = true`
let process = if is_less {
Self::make_process_from_less_path(
pager_path,
Expand All @@ -55,7 +54,6 @@ impl OutputType {
} else {
Self::make_process_from_pager_path(pager_path, args)
};
// FIXME: Commenting out this and just returning `OutputType::stdout()` fixes the problem
if let Some(mut process) = process {
process
.stdin(Stdio::piped())
Expand Down

0 comments on commit ec953eb

Please sign in to comment.