cli: use pager for files

The output from `files` is often longer than a screen, so the pager is
useful, even though this command is probably used mostly by
scripts. As with `status`, `hg` pages its output, but `git` doesn't.
This commit is contained in:
Martin von Zweigbergk 2022-12-04 06:14:38 -08:00 committed by Martin von Zweigbergk
parent cb9ba5abc1
commit 8e994a28fe

View file

@ -1245,6 +1245,7 @@ fn cmd_files(ui: &mut Ui, command: &CommandHelper, args: &FilesArgs) -> Result<(
let workspace_command = command.workspace_helper(ui)?; let workspace_command = command.workspace_helper(ui)?;
let commit = workspace_command.resolve_single_rev(&args.revision)?; let commit = workspace_command.resolve_single_rev(&args.revision)?;
let matcher = workspace_command.matcher_from_values(&args.paths)?; let matcher = workspace_command.matcher_from_values(&args.paths)?;
ui.request_pager();
for (name, _value) in commit.tree().entries_matching(matcher.as_ref()) { for (name, _value) in commit.tree().entries_matching(matcher.as_ref()) {
writeln!(ui, "{}", &workspace_command.format_file_path(&name))?; writeln!(ui, "{}", &workspace_command.format_file_path(&name))?;
} }