Skip to content

Commit

Permalink
filled out help_view option and implemented logic to trigger it
Browse files Browse the repository at this point in the history
  • Loading branch information
nathangavin committed Sep 28, 2024
1 parent 944fd94 commit c5bbd12
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 9 deletions.
9 changes: 4 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use model::utils_model::RunningMode;

use view::default_view::render_ui as default_render;
use view::debug_view::render_ui as debug_render;
use view::help_view::print_help_text;
use controller::default_controller::run;
use utils::handle_args::handle_input_args;
//use controller::debugController::run as run_debug;
Expand All @@ -37,11 +38,9 @@ fn main() -> Result<(), io::Error>{
}
};

match running_mode {
RunningMode::Help => {
return Ok(());
}
_ => {}
if running_mode == RunningMode::Help {
print_help_text();
return Ok(());
}

enable_raw_mode()?;
Expand Down
2 changes: 1 addition & 1 deletion src/model/utils_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub enum _InsertMode {
Removing
}

#[derive(Debug)]
#[derive(Debug, PartialEq)]
pub enum RunningMode {
Normal,
Debug,
Expand Down
7 changes: 6 additions & 1 deletion src/utils/handle_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,13 @@ pub fn handle_input_args(args: Vec<String>)

},
"-d"|"--debug" => {
running_mode = RunningMode::Debug;
if running_mode != RunningMode::Help {
running_mode = RunningMode::Debug;
}
},
"-h"|"--help" => {
running_mode = RunningMode::Help;
}
_ => {}
};
}
Expand Down
1 change: 1 addition & 0 deletions src/view.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pub mod default_view;
pub mod debug_view;
pub mod help_view;
2 changes: 0 additions & 2 deletions src/view/default_view.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::io;

use tui::{
backend::Backend,
widgets::{
Expand Down
23 changes: 23 additions & 0 deletions src/view/help_view.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
pub fn print_help_text() {
let help_text = "
Usage:
csv-tui [options] Run CSV editor
Options:
-h, --help Print this help message
-f, --filename Open file defined in next arg in editor
-d, --debug Run CSV editor in Debug mode
-c, --comma Set the CSV delimiter to comma
-t, --tab Set the CSV delimiter to tab
-sc, --semicolon Set the CSV delimiter to semicolon
-s, --space Set the CSV delimiter to space
Examples:
csv-tui Opens empty editor
csv-tui -f test.csv Opens test.csv into the editor
csv-tui -f test.csv -sc Tries to open test.csv using semicolon as delimiter
csv-tui --tab Opens empty editor, setting delimiter to tab
csv-tui --debug Opens empty editor in debug mode
";
println!("{}", help_text);
}

0 comments on commit c5bbd12

Please sign in to comment.