MCPcopy
hub / github.com/awslabs/aws-shell / ShellLexer

Class ShellLexer

awsshell/lexer.py:20–62  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

18
19
20class 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 }

Callers

nothing calls this directly

Calls 2

CompletionIndexClass · 0.90
load_completionsMethod · 0.80

Tested by

no test coverage detected