summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTim Oram <dev@mitmaro.ca>2018-04-01 12:03:04 -0230
committerTim Oram <dev@mitmaro.ca>2018-04-01 12:06:03 -0230
commitb369acdc7d2a018d28c73b29866b0f98611f0bc1 (patch)
tree4813ea43125be59e6c351fb7ebcf2cdbe673f278 /src
parent740821b7d8c9f664a82f94b69fa4dab795b400da (diff)
Switch to clap for arguments and add --help
Diffstat (limited to 'src')
-rw-r--r--src/cli.rs13
-rw-r--r--src/main.rs28
2 files changed, 19 insertions, 22 deletions
diff --git a/src/cli.rs b/src/cli.rs
new file mode 100644
index 0000000..3c59c68
--- /dev/null
+++ b/src/cli.rs
@@ -0,0 +1,13 @@
+
+use clap::{App};
+
+const NAME: &str = "interactive-rebase-tool";
+const VERSION: &str = env!("CARGO_PKG_VERSION");
+
+pub fn build_cli() -> App<'static, 'static> {
+ App::new(NAME)
+ .version(VERSION)
+ .about("Full feature terminal based sequence editor for git interactive rebase.")
+ .author("Tim Oram <dev@mitmaro.ca>")
+ .args_from_usage("<rebase-todo-filepath> 'The path to the git rebase todo file'")
+} \ No newline at end of file
diff --git a/src/main.rs b/src/main.rs
index e737a2a..85f5632 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,11 +1,13 @@
#![cfg_attr(feature="clippy", feature(plugin))]
#![cfg_attr(feature="clippy", plugin(clippy))]
+extern crate clap;
extern crate pad;
extern crate pancurses;
mod action;
mod application;
+mod cli;
mod commit;
mod git_interactive;
mod line;
@@ -15,33 +17,15 @@ mod mocks;
use application::Application;
use git_interactive::GitInteractive;
-use std::env;
use std::process;
use window::Window;
-const VERSION: &str = env!("CARGO_PKG_VERSION");
-
fn main() {
- let filepath = match env::args().nth(1) {
- Some(arg) => {
- match arg.as_ref() {
- "--version" | "-v" => {
- println!("v{}", VERSION);
- process::exit(0);
- },
- _ => arg
- }
- },
- None => {
- eprintln!(
- "Must provide a filepath.\n\n\
- Usage: interactive-rebase-tool <filepath>"
- );
- process::exit(1)
- }
- };
+ let matches = cli::build_cli().get_matches();
+
+ let filepath = matches.value_of("rebase-todo-filepath").unwrap();
- let git_interactive = match GitInteractive::new_from_filepath(&filepath) {
+ let git_interactive = match GitInteractive::new_from_filepath(filepath) {
Ok(gi) => gi,
Err(msg) => {
eprintln!("{}", msg);