feat(cli): add a --ui-scale [0,100] cli parameter (#492)

This commit is contained in:
Alexandre Pasmantier 2025-05-01 20:46:05 +02:00 committed by GitHub
parent 64c599ef10
commit f887a2390e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 33 additions and 4 deletions

View File

@ -1,10 +1,10 @@
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.TH television 1 "television 0.11.8"
.TH television 1 "television 0.11.9"
.SH NAME
television \- A cross\-platform, fast and extensible general purpose fuzzy finder TUI.
.SH SYNOPSIS
\fBtelevision\fR [\fB\-p\fR|\fB\-\-preview\fR] [\fB\-\-no\-preview\fR] [\fB\-\-delimiter\fR] [\fB\-t\fR|\fB\-\-tick\-rate\fR] [\fB\-f\fR|\fB\-\-frame\-rate\fR] [\fB\-k\fR|\fB\-\-keybindings\fR] [\fB\-i\fR|\fB\-\-input\fR] [\fB\-\-custom\-header\fR] [\fB\-\-autocomplete\-prompt\fR] [\fB\-\-select\-1\fR] [\fB\-\-no\-remote\fR] [\fB\-\-no\-help\fR] [\fB\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR] [\fICHANNEL\fR] [\fIPATH\fR] [\fIsubcommands\fR]
\fBtelevision\fR [\fB\-p\fR|\fB\-\-preview\fR] [\fB\-\-no\-preview\fR] [\fB\-\-delimiter\fR] [\fB\-t\fR|\fB\-\-tick\-rate\fR] [\fB\-f\fR|\fB\-\-frame\-rate\fR] [\fB\-k\fR|\fB\-\-keybindings\fR] [\fB\-i\fR|\fB\-\-input\fR] [\fB\-\-custom\-header\fR] [\fB\-\-autocomplete\-prompt\fR] [\fB\-\-exact\fR] [\fB\-\-select\-1\fR] [\fB\-\-no\-remote\fR] [\fB\-\-no\-help\fR] [\fB\-\-ui\-scale\fR] [\fB\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR] [\fICHANNEL\fR] [\fIPATH\fR] [\fIsubcommands\fR]
.SH DESCRIPTION
A cross\-platform, fast and extensible general purpose fuzzy finder TUI.
.SH OPTIONS
@ -73,6 +73,13 @@ This can be used to automatically select a channel based on the input
prompt by using the `shell_integration` mapping in the configuration
file.
.TP
\fB\-\-exact\fR
Use substring matching instead of fuzzy matching.
This will use substring matching instead of fuzzy matching when
searching for entries. This is useful when the user wants to search for
an exact match instead of a fuzzy match e.g. to improve performance.
.TP
\fB\-\-select\-1\fR
Automatically select and output the first entry if there is only one
entry.
@ -102,13 +109,19 @@ when the user wants `tv` to run with a minimal interface (e.g. when
using it as a file picker for a script or embedding it in a larger
application).
.TP
\fB\-\-ui\-scale\fR=\fIINTEGER\fR [default: 100]
Change the display size in relation to the available area.
This will crop the UI to a centered rectangle of the specified
percentage of the available area (e.g. 0.5 for 50% x 50%).
.TP
\fB\-h\fR, \fB\-\-help\fR
Print help (see a summary with \*(Aq\-h\*(Aq)
.TP
\fB\-V\fR, \fB\-\-version\fR
Print version
.TP
[\fICHANNEL\fR] [default: files]
[\fICHANNEL\fR]
Which channel shall we watch?
A list of the available channels can be displayed using the
@ -133,6 +146,6 @@ Initializes shell completion ("tv init zsh")
television\-help(1)
Print this message or the help of the given subcommand(s)
.SH VERSION
v0.11.8
v0.11.9
.SH AUTHORS
Alexandre Pasmantier <alex.pasmant@gmail.com>

View File

@ -134,6 +134,18 @@ pub struct Cli {
#[arg(long, default_value = "false", verbatim_doc_comment)]
pub no_help: bool,
/// Change the display size in relation to the available area.
///
/// This will crop the UI to a centered rectangle of the specified
/// percentage of the available area (e.g. 0.5 for 50% x 50%).
#[arg(
long,
value_name = "INTEGER",
default_value = "100",
verbatim_doc_comment
)]
pub ui_scale: u16,
#[command(subcommand)]
pub command: Option<Command>,
}

View File

@ -37,6 +37,7 @@ pub struct PostProcessedCli {
pub select_1: bool,
pub no_remote: bool,
pub no_help: bool,
pub ui_scale: u16,
}
impl Default for PostProcessedCli {
@ -57,6 +58,7 @@ impl Default for PostProcessedCli {
select_1: false,
no_remote: false,
no_help: false,
ui_scale: 100,
}
}
}
@ -141,6 +143,7 @@ impl From<Cli> for PostProcessedCli {
select_1: cli.select_1,
no_remote: cli.no_remote,
no_help: cli.no_help,
ui_scale: cli.ui_scale,
}
}
}

View File

@ -114,6 +114,7 @@ fn apply_cli_overrides(args: &PostProcessedCli, config: &mut Config) {
if let Some(header) = &args.custom_header {
config.ui.custom_header = Some(header.to_string());
}
config.ui.ui_scale = args.ui_scale;
}
pub fn set_current_dir(path: &String) -> Result<()> {