summaryrefslogtreecommitdiff
path: root/plac/doc/example13.py
blob: 715f2e194ca5beaac16ab7cd2057dee3c6d26f5f (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
import plac

class FVCS(object):
    "A Fake Version Control System"
    commands = 'checkout', 'commit', 'status', 'help'

    @plac.annotations(
        name=('a recognized command', 'positional', None, str, commands))
    def help(self, name):
        print(plac.parser_from(self).help_cmd(name))

    @plac.annotations(
        url=('url of the source code', 'positional'))
    def checkout(self, url):
        print('checkout', url)

    def commit(self):
        print('commit')

    @plac.annotations(quiet=('summary information', 'flag'))
    def status(self, quiet):
        print('status', quiet)

main = FVCS()

if __name__ == '__main__':
    plac.call(main)