diff --git a/src/app/key_binding.rs b/src/app/key_binding.rs index edcaa85..b36ce13 100644 --- a/src/app/key_binding.rs +++ b/src/app/key_binding.rs @@ -50,15 +50,13 @@ generate_keybindings! { jump_to_deployments, jump_to_jobs, jump_to_daemonsets, - jump_to_more_resources, - cycle_group_by + jump_to_more_resources } #[derive(PartialEq, Eq, Clone, Copy, Hash, Debug)] pub enum HContext { General, Overview, - Utilization, } impl fmt::Display for HContext { @@ -274,12 +272,6 @@ pub const DEFAULT_KEYBINDING: KeyBindings = KeyBindings { desc: "Select more resources", context: HContext::Overview, }, - cycle_group_by: KeyBinding { - key: Key::Char('g'), - alt: None, - desc: "Cycle through grouping", - context: HContext::Utilization, - }, }; pub fn get_help_docs() -> Vec> { diff --git a/src/banner.rs b/src/banner.rs index 12b3e81..ca9a348 100644 --- a/src/banner.rs +++ b/src/banner.rs @@ -1,6 +1,6 @@ pub const BANNER: &str = " - __ _ __ __ _ ___ _ _ -| \\| | V | |/ / | | | | -| | ' | \\_/ | <| | |_| |_ -|_|\\__|_| |_|_|\\_\\_|___|___| + ___ _______ + / _ \\___ _ __/ ___/ /__ ___ ____ ___ ____ + / // / -_) |/ / /__/ / -_) _ `/ _ \\/ -_) __/ +/____/\\__/|___/\\___/_/\\__/\\_,_/_//_/\\__/_/ "; diff --git a/src/cli.rs b/src/cli.rs index b931062..da74192 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1,4 +1,5 @@ use clap::{App as ClapApp, Arg}; +use std::env; use super::banner::BANNER; @@ -15,7 +16,7 @@ pub struct Cli { impl Cli { pub fn new() -> Cli { Cli { - path: "".to_string(), + path: env::current_dir().unwrap().to_str().unwrap().to_string(), criteria: "node_modules".into(), enhanced_graphics: true, } @@ -33,7 +34,6 @@ impl Cli { Arg::with_name("path") .short("p") .long("path") - .required(true) .help("Set the path to scan for the criteria.") .takes_value(true), ) diff --git a/src/main.rs b/src/main.rs index d7eb3ce..d1ca0d1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -55,7 +55,7 @@ async fn main() -> Result<()> { Ok(()) } -async fn start_ui(_cli: Cli, app: &Arc>) -> Result<()> { +async fn start_ui(cli: Cli, app: &Arc>) -> Result<()> { // Terminal initialization let mut stdout = stdout(); // not capturing mouse to make text select/copy possible @@ -89,7 +89,7 @@ async fn start_ui(_cli: Cli, app: &Arc>) -> Result<()> { } }; // draw the UI layout - terminal.draw(|f| ui::draw(f, &mut app))?; + terminal.draw(|f| ui::draw(f, &mut app, &cli))?; // handle key events match events.next()? { diff --git a/src/ui/mod.rs b/src/ui/mod.rs index af966ab..f19fb08 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -1,8 +1,3 @@ -mod control_panel; -mod help; -mod overview; -mod utils; - use tui::{ backend::Backend, layout::{Constraint, Rect}, @@ -11,16 +6,23 @@ use tui::{ Frame, }; +use crate::app::{App, RouteId}; +use crate::Cli; + use self::{ help::draw_help, overview::draw_overview, utils::{style_failure, style_main_background, style_primary, vertical_chunks}, }; -use crate::app::{App, RouteId}; + +mod control_panel; +mod help; +mod overview; +mod utils; static HIGHLIGHT: &str = "=> "; -pub fn draw(f: &mut Frame, app: &mut App) { +pub fn draw(f: &mut Frame, app: &mut App, cli: &Cli) { let block = Block::default().style(style_main_background(app.light_theme)); f.render_widget(block, f.size()); @@ -45,7 +47,7 @@ pub fn draw(f: &mut Frame, app: &mut App) { draw_help(f, app, last_chunk); } _ => { - draw_overview(f, app, last_chunk); + draw_overview(f, app, cli, last_chunk); } } } diff --git a/src/ui/overview.rs b/src/ui/overview.rs index 69a45dd..fbcf171 100644 --- a/src/ui/overview.rs +++ b/src/ui/overview.rs @@ -12,27 +12,27 @@ use tui::{ use crate::app::RouteId; use crate::ui::control_panel::draw_control_panel_block; use crate::ui::utils::{layout_block, style_help, title_style_logo}; -use crate::{app::App, banner::BANNER}; +use crate::{app::App, banner::BANNER, Cli}; use super::utils::{ horizontal_chunks, style_default, style_logo, style_primary, vertical_chunks, vertical_chunks_with_margin, }; -pub fn draw_overview(f: &mut Frame, app: &mut App, area: Rect) { +pub fn draw_overview(f: &mut Frame, app: &mut App, cli: &Cli, area: Rect) { if app.show_info_bar { let chunks = vertical_chunks(vec![Constraint::Length(9), Constraint::Min(10)], area); - draw_status_block(f, app, chunks[0]); + draw_status_block(f, app, cli, chunks[0]); draw_control_panel_block(f, app, chunks[1]); } else { draw_control_panel_block(f, app, area); } } -fn draw_status_block(f: &mut Frame, app: &mut App, area: Rect) { - let chunks = horizontal_chunks(vec![Constraint::Min(10), Constraint::Length(40)], area); +fn draw_status_block(f: &mut Frame, app: &mut App, cli: &Cli, area: Rect) { + let chunks = horizontal_chunks(vec![Constraint::Min(10), Constraint::Length(50)], area); - draw_context_info_block(f, app, chunks[0]); + draw_general_info_block(f, app, cli, chunks[0]); draw_logo_block(f, app, chunks[1]); } @@ -52,10 +52,10 @@ fn draw_logo_block(f: &mut Frame, app: &mut App, area: Rect) { f.render_widget(paragraph, area); } -fn draw_context_info_block(f: &mut Frame, app: &mut App, area: Rect) { +fn draw_general_info_block(f: &mut Frame, app: &mut App, cli: &Cli, area: Rect) { let chunks = vertical_chunks_with_margin( vec![ - Constraint::Length(3), + Constraint::Length(4), Constraint::Min(2), Constraint::Min(2), ], @@ -74,6 +74,14 @@ fn draw_context_info_block(f: &mut Frame, app: &mut App, area: Re project_size += project.size; } let text = vec![ + Spans::from(vec![ + Span::styled("Path: ", style_default(app.light_theme)), + Span::styled(cli.path.clone(), style_primary()), + ]), + Spans::from(vec![ + Span::styled("Criteria: ", style_default(app.light_theme)), + Span::styled(cli.criteria.clone(), style_primary()), + ]), Spans::from(vec![ Span::styled("Projects: ", style_default(app.light_theme)), Span::styled(project_count.to_string(), style_primary()), @@ -93,7 +101,7 @@ fn draw_context_info_block(f: &mut Frame, app: &mut App, area: Re fn draw_header_text(f: &mut Frame, app: &mut App, area: Rect) { let text = match app.get_current_route().id { RouteId::Home => vec![Spans::from( - ": scroll context | : select context | more help", + ": move | : select and delete | more help", )], _ => vec![Spans::from(" more help")], };