moving to config.toml
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// src/client/terminal.rs
|
||||
use crossterm::event::{self, Event};
|
||||
use crossterm::event::{self, Event, KeyCode, KeyModifiers};
|
||||
use crossterm::{
|
||||
execute,
|
||||
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
|
||||
@@ -8,6 +8,7 @@ use ratatui::{backend::CrosstermBackend, Terminal};
|
||||
use std::io::{self, stdout};
|
||||
use tonic::transport::Channel;
|
||||
use crate::proto::multieko2::adresar_client::AdresarClient;
|
||||
use crate::client::config::Config;
|
||||
use crate::proto::multieko2::AdresarRequest;
|
||||
|
||||
pub struct AppTerminal {
|
||||
@@ -49,12 +50,12 @@ impl AppTerminal {
|
||||
|
||||
pub async fn handle_command(
|
||||
&mut self,
|
||||
command_input: &str,
|
||||
action: &str,
|
||||
is_saved: &mut bool,
|
||||
form_data: &AdresarRequest, // Pass form data here
|
||||
form_data: &AdresarRequest,
|
||||
) -> Result<(bool, String), Box<dyn std::error::Error>> {
|
||||
match command_input {
|
||||
"w" => {
|
||||
match action {
|
||||
"save" => {
|
||||
// Send data to the server
|
||||
let request = tonic::Request::new(form_data.clone());
|
||||
let response = self.grpc_client.create_adresar(request).await?;
|
||||
@@ -62,7 +63,7 @@ impl AppTerminal {
|
||||
*is_saved = true;
|
||||
Ok((false, format!("State saved. Response: {:?}", response)))
|
||||
}
|
||||
"q" => {
|
||||
"quit" => {
|
||||
if *is_saved {
|
||||
self.cleanup()?;
|
||||
Ok((true, "Exiting.".to_string()))
|
||||
@@ -70,16 +71,16 @@ impl AppTerminal {
|
||||
Ok((false, "No changes saved. Use :q! to force quit.".to_string()))
|
||||
}
|
||||
}
|
||||
"q!" => {
|
||||
"force_quit" => {
|
||||
self.cleanup()?;
|
||||
Ok((true, "Force exiting without saving.".to_string()))
|
||||
}
|
||||
"wq" => {
|
||||
"save_and_quit" => {
|
||||
*is_saved = true;
|
||||
self.cleanup()?;
|
||||
Ok((true, "State saved. Exiting.".to_string()))
|
||||
}
|
||||
_ => Ok((false, format!("Command not recognized: {}", command_input))),
|
||||
_ => Ok((false, format!("Action not recognized: {}", action))),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user