mirror of
https://github.com/martinvonz/jj.git
synced 2025-02-08 21:48:08 +00:00
cli: use pager for print
The `print` command shows the contents of a file, so that is obviously often more than a page long. Both `hg cat file` and `git show HEAD:file` page the output.
This commit is contained in:
parent
8e994a28fe
commit
dc8830843e
1 changed files with 2 additions and 0 deletions
|
@ -1263,12 +1263,14 @@ fn cmd_print(ui: &mut Ui, command: &CommandHelper, args: &PrintArgs) -> Result<(
|
|||
}
|
||||
Some(TreeValue::File { id, .. }) => {
|
||||
let mut contents = repo.store().read_file(&path, &id)?;
|
||||
ui.request_pager();
|
||||
std::io::copy(&mut contents, &mut ui.stdout_formatter().as_mut())?;
|
||||
}
|
||||
Some(TreeValue::Conflict(id)) => {
|
||||
let conflict = repo.store().read_conflict(&path, &id)?;
|
||||
let mut contents = vec![];
|
||||
conflicts::materialize_conflict(repo.store(), &path, &conflict, &mut contents).unwrap();
|
||||
ui.request_pager();
|
||||
ui.stdout_formatter().write_all(&contents)?;
|
||||
}
|
||||
_ => {
|
||||
|
|
Loading…
Reference in a new issue