Skip to content

Commit

Permalink
🦀 feat(ux): add a minimum size bypass cli flag (ChrisTitusTech#920)
Browse files Browse the repository at this point in the history
* 🦀 feat(ux): add a minimum size bypass cli flag

* oopsie
  • Loading branch information
adamperkowski authored Nov 6, 2024
1 parent 565f507 commit f0734f3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
4 changes: 4 additions & 0 deletions man/linutil.1
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ Defaults to \fIdefault\fR.
\fB\-\-override\-validation\fR
Show all available entries, disregarding compatibility checks. (\fBUNSAFE\fR)

.TP
\fB\-\-size\-bypass\fR
Bypass the terminal size limit

.TP
\fB\-h\fR, \fB\-\-help\fR
Print help.
Expand Down
5 changes: 4 additions & 1 deletion tui/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,15 @@ struct Args {
#[arg(long, default_value_t = false)]
#[clap(help = "Show all available options, disregarding compatibility checks (UNSAFE)")]
override_validation: bool,
#[arg(long, default_value_t = false)]
#[clap(help = "Bypass the terminal size limit")]
size_bypass: bool,
}

fn main() -> io::Result<()> {
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)?;
enable_raw_mode()?;
Expand Down
8 changes: 6 additions & 2 deletions tui/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ pub struct AppState {
drawable: bool,
#[cfg(feature = "tips")]
tip: String,
size_bypass: bool,
}

pub enum Focus {
Expand All @@ -86,7 +87,7 @@ enum SelectedItem {
}

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 root_id = tabs[0].tree.root().id();

Expand All @@ -104,6 +105,7 @@ impl AppState {
drawable: false,
#[cfg(feature = "tips")]
tip: get_random_tip(),
size_bypass,
};

state.update_items();
Expand Down Expand Up @@ -186,7 +188,9 @@ impl AppState {
pub fn draw(&mut self, frame: &mut Frame) {
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!(
"Terminal size too small:\nWidth = {} Height = {}\n\nMinimum size:\nWidth = {} Height = {}",
terminal_size.width,
Expand Down

0 comments on commit f0734f3

Please sign in to comment.