diff options
author | NerdyPepper <[email protected]> | 2019-06-18 07:52:07 +0100 |
---|---|---|
committer | NerdyPepper <[email protected]> | 2019-06-18 07:52:07 +0100 |
commit | 1a06f12da5e701b778009fc5c81db28f092fcede (patch) | |
tree | 41aa18e98550c263e04a17d085a40b7bb7d8a561 | |
parent | 2eda7d259dc7529ddaf52c30558d1e0432217959 (diff) |
add history hinting
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | readme.md | 6 | ||||
-rw-r--r-- | src/main.rs | 9 |
3 files changed, 12 insertions, 5 deletions
@@ -12,7 +12,7 @@ categories = ["command-line-interface", "science", "parser-implementations"] | |||
12 | license = "MIT" | 12 | license = "MIT" |
13 | 13 | ||
14 | [dependencies] | 14 | [dependencies] |
15 | rustyline = "3.0.0" | 15 | rustyline = "4.0.0" |
16 | clap = "2.32.0" | 16 | clap = "2.32.0" |
17 | radix_fmt = "0.1.1" | 17 | radix_fmt = "0.1.1" |
18 | lazy_static = "1.3.0" | 18 | lazy_static = "1.3.0" |
@@ -23,7 +23,7 @@ $ cargo run | |||
23 | ### usage | 23 | ### usage |
24 | 24 | ||
25 | ```shell | 25 | ```shell |
26 | eva 0.2.3 | 26 | eva 0.2.4 |
27 | NerdyPepper <[email protected]> | 27 | NerdyPepper <[email protected]> |
28 | Calculator REPL similar to bc(1) | 28 | Calculator REPL similar to bc(1) |
29 | 29 | ||
@@ -36,10 +36,12 @@ FLAGS: | |||
36 | -V, --version Prints version information | 36 | -V, --version Prints version information |
37 | 37 | ||
38 | OPTIONS: | 38 | OPTIONS: |
39 | -f, --fix <FIX> set number of decimal places in the output | 39 | -b, --base <RADIX> set the radix of calculation output (2, 8, 10, 16 etc.) |
40 | -f, --fix <FIX> set number of decimal places in the output | ||
40 | 41 | ||
41 | ARGS: | 42 | ARGS: |
42 | <INPUT> optional expression string to run eva in command mode | 43 | <INPUT> optional expression string to run eva in command mode |
44 | |||
43 | ``` | 45 | ``` |
44 | 46 | ||
45 | type out an expression and hit enter, repeat. | 47 | type out an expression and hit enter, repeat. |
diff --git a/src/main.rs b/src/main.rs index 5846a87..ffdb690 100644 --- a/src/main.rs +++ b/src/main.rs | |||
@@ -20,10 +20,14 @@ use crate::format::*; | |||
20 | // extern crates | 20 | // extern crates |
21 | use rustyline::error::ReadlineError; | 21 | use rustyline::error::ReadlineError; |
22 | use rustyline::Editor; | 22 | use rustyline::Editor; |
23 | use rustyline::config::{ Builder, ColorMode, EditMode }; | 23 | use rustyline::config::{ Builder, ColorMode, EditMode, CompletionType }; |
24 | use rustyline::highlight::{ Highlighter, MatchingBracketHighlighter }; | ||
25 | use rustyline::hint::{ Hinter, HistoryHinter }; | ||
24 | use clap::{Arg, App}; | 26 | use clap::{Arg, App}; |
25 | use lazy_static::lazy_static; | 27 | use lazy_static::lazy_static; |
26 | 28 | ||
29 | struct LineHelper (MatchingBracketHighlighter, HistoryHinter); | ||
30 | |||
27 | struct Configuration { | 31 | struct Configuration { |
28 | radian_mode: bool, | 32 | radian_mode: bool, |
29 | fix: usize, | 33 | fix: usize, |
@@ -50,6 +54,7 @@ fn main() { | |||
50 | let config = config_builder.color_mode(ColorMode::Enabled) | 54 | let config = config_builder.color_mode(ColorMode::Enabled) |
51 | .edit_mode(EditMode::Emacs) | 55 | .edit_mode(EditMode::Emacs) |
52 | .history_ignore_space(true) | 56 | .history_ignore_space(true) |
57 | .completion_type(CompletionType::Circular) | ||
53 | .max_history_size(1000) | 58 | .max_history_size(1000) |
54 | .build(); | 59 | .build(); |
55 | let mut rl = Editor::<()>::with_config(config); | 60 | let mut rl = Editor::<()>::with_config(config); |
@@ -102,7 +107,7 @@ fn parse_arguments() -> Configuration { | |||
102 | .long("base") | 107 | .long("base") |
103 | .takes_value(true) | 108 | .takes_value(true) |
104 | .value_name("RADIX") | 109 | .value_name("RADIX") |
105 | .help("set the radix of calculation output (2, 8, 10, 16 etc.)")) | 110 | .help("set the radix of calculation output (1 - 36)")) |
106 | .arg(Arg::with_name("INPUT") | 111 | .arg(Arg::with_name("INPUT") |
107 | .help("optional expression string to run eva in command mode") | 112 | .help("optional expression string to run eva in command mode") |
108 | .index(1)) | 113 | .index(1)) |