Skip to content

Commit

Permalink
Make input mode configurable via command-line
Browse files Browse the repository at this point in the history
  • Loading branch information
brouberol committed Apr 7, 2018
1 parent 422221c commit 0d161fa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ optional arguments:
--style {default,emacs, ...}
The color style to adopt. Default: monokai. Override
via the IZK_STYLE environment variable.
--input-mode {vi,emacs}
The input mode to adopt. Default: vi. Override via the
IZK_INPUT_MODE environment variable.
--version Display izk version number and exit
Version: 0.3.1
Expand Down
9 changes: 8 additions & 1 deletion izk/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

DEFAULT_ZK_URL = 'localhost:2181'
DEFAULT_COLOR_STYLE = 'monokai'
DEFAULT_INPUT_MODE = 'vi'


class EnvDefault(argparse.Action):
Expand Down Expand Up @@ -84,6 +85,12 @@ def parse_args():
action=EnvDefault,
default=DEFAULT_COLOR_STYLE,
choices=STYLE_NAMES)
parser.add_argument(
'--input-mode',
help="The input mode to adopt. Default: %s" % (DEFAULT_INPUT_MODE),
action=EnvDefault,
default=DEFAULT_INPUT_MODE,
choices=('vi', 'emacs'))
parser.add_argument(
'--version',
help="Display izk version number and exit",
Expand Down Expand Up @@ -124,7 +131,7 @@ def main(): # pragma: no cover
completer=completer,
lexer=ZkCliLexer,
style=g.style,
vi_mode=True)
vi_mode=args.mode == 'vi')
try:
out = cmdrunner.run(cmd)
except CommandValidationError as exc:
Expand Down

0 comments on commit 0d161fa

Please sign in to comment.