summaryrefslogtreecommitdiff
path: root/util/cmdline_lexer.py
blob: 4927325a02373d58c9536d0dc5301bcaa99e45a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python
'''
cmdline_lexer.py - this file is part of S3QL (http://s3ql.googlecode.com)

Copyright (C) 2008-2009 Nikolaus Rath <Nikolaus@rath.org>

This program can be distributed under the terms of the GNU GPLv3.
'''

from pygments.token import Comment, Name, Generic, Literal
from pygments.lexer import RegexLexer

__all__ = [ 'CommandLineLexer' ]

class CommandLineLexer(RegexLexer):
    """
    A lexer that highlights a command line with variable parts
    """

    name = 'CommandLine'
    aliases = ['commandline']
    mimetypes = []

    tokens = {
        'root': [
            (r'#.*\n', Comment),
            (r'[^[<]+', Literal),
            (r'\[[^[\]]+\]', Generic.Emph),
            (r'<[^>]+>', Name.Variable),
            ],

    }