Skip to content

Conversation

@donnemartin
Copy link
Contributor

Updated #27 with the following proposal:


A lexer would make it easier to visually distinguish the different components of a command:

 aws [options] <command> <subcommand> [parameters]

Config File

Default theme: vim

# visual theme. possible values: manni, igor, xcode, vim,
# autumn,vs, rrt, native, perldoc, borland, tango, emacs,
# friendly, monokai, paraiso-dark, colorful, murphy, bw,
# pastie, paraiso-light, trac, default, fruity.
# to disable themes, set theme = none
theme = vim

Disable Syntax Highlighting

 theme = none

Sample: Dark Background

 theme = vim

Imgur

Samples: Light Background

 theme = vim

Note: My terminal colors are customized which might be why we see light gray for aws>.

Imgur

 theme = xcode

Imgur

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block is straight from prompt_toolkit==0.52.

@donnemartin
Copy link
Contributor Author

I'll check out the tests.

IndexLoadError: [Errno 2] No such file or directory: '/home/travis/.aws/shell/cache/completions-1.9.14.json'

I have to remember to remove my local /.aws/shell/ directory next time to better simulate the Travis CI builds.

load_completions calls load_index, which can throw IndexLoadError if the index file doesn't exist.  load_completions now simply does nothing if the index file does not exist, resulting in no change to the attributes commands, subcommands, global_opts, and args_opts, each of which is a collection of strings.  If no completions exist because there's no index, it seems reasonable to return no completions.  Not throwing an exception with load_completions also simplifies integration tests.
CompletionIndex was recently refactored locally (prior to the initial commit for the lexer feature) to use attributes for commands, subcommands, args_opts, global_opts rather than returning the equivalent 4 element tuple in load_completions.  This change updates the tests accordingly.
Moving this out is more modular, as CompletionIndex() is created in two places in the source: main and lexer (possible refactor TODO item).  It's also called once in the tests.  This change also simplifies testing as we can more easily substitute a mock function, although this could also probably be achieved with a mock side effect.
@donnemartin
Copy link
Contributor Author

Follow-ups pass ci, should be ready for review.

@jamesls
Copy link
Member

jamesls commented Dec 24, 2015

:shipit: I've been trying this out locally. Looks great!

donnemartin added a commit that referenced this pull request Dec 24, 2015
Implements #27: Add lexer/syntax highlighting.
@donnemartin donnemartin merged commit 9149483 into master Dec 24, 2015
@donnemartin donnemartin deleted the lexer branch December 24, 2015 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants