mirror of
https://github.com/ChrisTitusTech/linutil.git
synced 2024-11-21 21:09:42 +00:00
🦀 feat(ux): add a minimum size bypass cli flag (#920)
* 🦀 feat(ux): add a minimum size bypass cli flag
* oopsie
This commit is contained in:
parent
565f507190
commit
f0734f361c
|
@ -36,6 +36,10 @@ Defaults to \fIdefault\fR.
|
||||||
\fB\-\-override\-validation\fR
|
\fB\-\-override\-validation\fR
|
||||||
Show all available entries, disregarding compatibility checks. (\fBUNSAFE\fR)
|
Show all available entries, disregarding compatibility checks. (\fBUNSAFE\fR)
|
||||||
|
|
||||||
|
.TP
|
||||||
|
\fB\-\-size\-bypass\fR
|
||||||
|
Bypass the terminal size limit
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
\fB\-h\fR, \fB\-\-help\fR
|
\fB\-h\fR, \fB\-\-help\fR
|
||||||
Print help.
|
Print help.
|
||||||
|
|
|
@ -33,12 +33,15 @@ struct Args {
|
||||||
#[arg(long, default_value_t = false)]
|
#[arg(long, default_value_t = false)]
|
||||||
#[clap(help = "Show all available options, disregarding compatibility checks (UNSAFE)")]
|
#[clap(help = "Show all available options, disregarding compatibility checks (UNSAFE)")]
|
||||||
override_validation: bool,
|
override_validation: bool,
|
||||||
|
#[arg(long, default_value_t = false)]
|
||||||
|
#[clap(help = "Bypass the terminal size limit")]
|
||||||
|
size_bypass: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> io::Result<()> {
|
fn main() -> io::Result<()> {
|
||||||
let args = Args::parse();
|
let args = Args::parse();
|
||||||
|
|
||||||
let mut state = AppState::new(args.theme, args.override_validation);
|
let mut state = AppState::new(args.theme, args.override_validation, args.size_bypass);
|
||||||
|
|
||||||
stdout().execute(EnterAlternateScreen)?;
|
stdout().execute(EnterAlternateScreen)?;
|
||||||
enable_raw_mode()?;
|
enable_raw_mode()?;
|
||||||
|
|
|
@ -62,6 +62,7 @@ pub struct AppState {
|
||||||
drawable: bool,
|
drawable: bool,
|
||||||
#[cfg(feature = "tips")]
|
#[cfg(feature = "tips")]
|
||||||
tip: String,
|
tip: String,
|
||||||
|
size_bypass: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum Focus {
|
pub enum Focus {
|
||||||
|
@ -86,7 +87,7 @@ enum SelectedItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AppState {
|
impl AppState {
|
||||||
pub fn new(theme: Theme, override_validation: bool) -> Self {
|
pub fn new(theme: Theme, override_validation: bool, size_bypass: bool) -> Self {
|
||||||
let (temp_dir, tabs) = linutil_core::get_tabs(!override_validation);
|
let (temp_dir, tabs) = linutil_core::get_tabs(!override_validation);
|
||||||
let root_id = tabs[0].tree.root().id();
|
let root_id = tabs[0].tree.root().id();
|
||||||
|
|
||||||
|
@ -104,6 +105,7 @@ impl AppState {
|
||||||
drawable: false,
|
drawable: false,
|
||||||
#[cfg(feature = "tips")]
|
#[cfg(feature = "tips")]
|
||||||
tip: get_random_tip(),
|
tip: get_random_tip(),
|
||||||
|
size_bypass,
|
||||||
};
|
};
|
||||||
|
|
||||||
state.update_items();
|
state.update_items();
|
||||||
|
@ -186,7 +188,9 @@ impl AppState {
|
||||||
pub fn draw(&mut self, frame: &mut Frame) {
|
pub fn draw(&mut self, frame: &mut Frame) {
|
||||||
let terminal_size = frame.area();
|
let terminal_size = frame.area();
|
||||||
|
|
||||||
if terminal_size.width < MIN_WIDTH || terminal_size.height < MIN_HEIGHT {
|
if !self.size_bypass
|
||||||
|
&& (terminal_size.height < MIN_HEIGHT || terminal_size.width < MIN_WIDTH)
|
||||||
|
{
|
||||||
let warning = Paragraph::new(format!(
|
let warning = Paragraph::new(format!(
|
||||||
"Terminal size too small:\nWidth = {} Height = {}\n\nMinimum size:\nWidth = {} Height = {}",
|
"Terminal size too small:\nWidth = {} Height = {}\n\nMinimum size:\nWidth = {} Height = {}",
|
||||||
terminal_size.width,
|
terminal_size.width,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user