Set title based on CLI Mode
This commit is contained in:
parent
6938960f3e
commit
783e31a582
1 changed files with 12 additions and 4 deletions
|
|
@ -21,17 +21,25 @@ use ratatui::{
|
||||||
use tokio::sync::mpsc::UnboundedSender;
|
use tokio::sync::mpsc::UnboundedSender;
|
||||||
|
|
||||||
use super::Component;
|
use super::Component;
|
||||||
use crate::{action::Action, config::Config};
|
use crate::{action::Action, cli, config::Config};
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Title {
|
pub struct Title {
|
||||||
command_tx: Option<UnboundedSender<Action>>,
|
command_tx: Option<UnboundedSender<Action>>,
|
||||||
config: Config,
|
config: Config,
|
||||||
|
title_text: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Title {
|
impl Title {
|
||||||
pub fn new() -> Self {
|
pub fn new(cli_cmd: cli::Command) -> Self {
|
||||||
Self::default()
|
let title_text = match cli_cmd {
|
||||||
|
cli::Command::Clone => String::from("Deja-Vu: Clone"),
|
||||||
|
cli::Command::Diagnose => String::from("Deja-Vu: Diagnostics"),
|
||||||
|
};
|
||||||
|
Self {
|
||||||
|
title_text,
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -55,7 +63,7 @@ impl Component for Title {
|
||||||
|
|
||||||
fn draw(&mut self, frame: &mut Frame, area: Rect) -> Result<()> {
|
fn draw(&mut self, frame: &mut Frame, area: Rect) -> Result<()> {
|
||||||
// Title Block
|
// Title Block
|
||||||
let title_text = Span::styled("WizardKit: Deja-Vu", Style::default().fg(Color::LightCyan));
|
let title_text = Span::styled(&self.title_text, Style::default().fg(Color::LightCyan));
|
||||||
let title = Paragraph::new(Line::from(title_text).centered())
|
let title = Paragraph::new(Line::from(title_text).centered())
|
||||||
.block(Block::default().borders(Borders::ALL));
|
.block(Block::default().borders(Borders::ALL));
|
||||||
frame.render_widget(title, area);
|
frame.render_widget(title, area);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue