Provides highlighting for commands, subcommands, arguments, and options. :type completion_index: :class:`CompletionIndex` :param completion_index: Completion index used to determine commands, subcommands, arguments, and options for highlighting. :type tokens: dict :param to
| 18 | |
| 19 | |
| 20 | class ShellLexer(RegexLexer): |
| 21 | """Provides highlighting for commands, subcommands, arguments, and options. |
| 22 | |
| 23 | :type completion_index: :class:`CompletionIndex` |
| 24 | :param completion_index: Completion index used to determine commands, |
| 25 | subcommands, arguments, and options for highlighting. |
| 26 | |
| 27 | :type tokens: dict |
| 28 | :param tokens: A dict of (`pygments.lexer`, `pygments.token`) used for |
| 29 | pygments highlighting. |
| 30 | """ |
| 31 | completion_index = CompletionIndex() |
| 32 | completion_index.load_completions() |
| 33 | tokens = { |
| 34 | 'root': [ |
| 35 | # ec2, s3, elb... |
| 36 | (words( |
| 37 | tuple(completion_index.commands), |
| 38 | prefix=r'\b', |
| 39 | suffix=r'\b'), |
| 40 | Literal.String), |
| 41 | # describe-instances |
| 42 | (words( |
| 43 | tuple(completion_index.subcommands), |
| 44 | prefix=r'\b', |
| 45 | suffix=r'\b'), |
| 46 | Name.Class), |
| 47 | # --instance-ids |
| 48 | (words( |
| 49 | tuple(list(completion_index.args_opts)), |
| 50 | prefix=r'', |
| 51 | suffix=r'\b'), |
| 52 | Keyword.Declaration), |
| 53 | # --profile |
| 54 | (words( |
| 55 | tuple(completion_index.global_opts), |
| 56 | prefix=r'', |
| 57 | suffix=r'\b'), |
| 58 | Operator.Word), |
| 59 | # Everything else |
| 60 | (r'.*\n', Text), |
| 61 | ] |
| 62 | } |
nothing calls this directly
no test coverage detected