mirror of
https://gitlab.com/fabinfra/fabaccess/sute.git
synced 2025-03-12 14:41:52 +01:00
Adds commands module
This commit is contained in:
parent
02c310aa67
commit
0a68ea405c
17
src/app.rs
17
src/app.rs
@ -58,14 +58,21 @@ impl<'a, S: Unpin> Sute<'a, S> {
|
||||
}
|
||||
}
|
||||
|
||||
fn run_cmd(&mut self, cmd: String) {
|
||||
if cmd == "quit" {
|
||||
self.state.running = false;
|
||||
} else {
|
||||
info!(self.log, "Issues unknown cmd: {}", cmd);
|
||||
fn run_cmd(&mut self, cmdline: String) {
|
||||
let mut words = cmdline.split_ascii_whitespace();
|
||||
match words.next() {
|
||||
Some("quit") => self.state.running = false,
|
||||
Some("connect") => {
|
||||
self.connect(cmdline)
|
||||
},
|
||||
cmd => info!(self.log, "Issues unknown cmd: {:?}", cmd),
|
||||
}
|
||||
}
|
||||
|
||||
fn connect(&mut self, params: String) {
|
||||
info!(self.log, "Called connect with {}", params);
|
||||
}
|
||||
|
||||
fn handle_resize(&mut self, new_size: (u16,u16)) {
|
||||
self.state.size = new_size;
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ mod input;
|
||||
mod util;
|
||||
mod ui;
|
||||
mod schema;
|
||||
mod commands;
|
||||
|
||||
use banner::BANNER;
|
||||
|
||||
@ -71,6 +72,7 @@ fn main() -> Result<(), io::Error> {
|
||||
|
||||
let app = app::Sute::new(resize, log.clone(), drain, api);
|
||||
|
||||
let mut state = app.get_state();
|
||||
let mut stream = app.to_stream();
|
||||
|
||||
let ui_future = async move {
|
||||
@ -86,6 +88,7 @@ fn main() -> Result<(), io::Error> {
|
||||
terminal.resize(tui::layout::Rect::new(0, 0, x,y)).unwrap();
|
||||
}
|
||||
|
||||
terminal.draw(|f| ui::draw_ui(f, &mut state));
|
||||
loop {
|
||||
if let Some(mut state) = stream.next().await {
|
||||
if !state.running {
|
||||
|
@ -26,7 +26,7 @@ pub fn draw_ui<B: Backend>(f: &mut Frame<B>, app: &mut SuteState) {
|
||||
|
||||
fn draw_header<B: Backend>(f: &mut Frame<B>, app: &mut SuteState, layout_chunk: Rect) {
|
||||
f.render_widget(Block::default()
|
||||
.title("Header")
|
||||
.title("Status")
|
||||
.borders(Borders::ALL), layout_chunk);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user