File: sample.py

package info (click to toggle)
sphinx-argparse 0.5.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 288 kB
  • sloc: python: 1,514; makefile: 133
file content (63 lines) | stat: -rw-r--r-- 2,068 bytes parent folder | download
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import argparse

parser = argparse.ArgumentParser()

subparsers = parser.add_subparsers()

my_command1 = subparsers.add_parser(
    'apply', help='Execute provision script, collect all resources and apply them.'
)

my_command1.add_argument(
    'path',
    help='Specify path to provision script. '
    'provision.py in current directory by default. '
    'Also may include url.',
    default='provision.py',
)
my_command1.add_argument(
    '-r',
    '--rollback',
    action='store_true',
    default=False,
    help='If specified will rollback all resources applied.',
)
my_command1.add_argument(
    '--tree', action='store_true', default=False, help='Print resource tree'
)
my_command1.add_argument(
    '--dry', action='store_true', default=False, help='Just print changes list'
)
my_command1.add_argument(
    '--force', action='store_true', default=False, help='Apply without confirmation'
)
my_command1.add_argument(
    'default_string',
    default='I am a default',
    help='Ensure variables are filled in %(prog)s (default %(default)s)',
)

my_command2 = subparsers.add_parser('game', help='Decision games')
my_command2.add_argument(
    'move', choices=['rock', 'paper', 'scissors'], help='Choices for argument example'
)
my_command2.add_argument(
    '--opt', choices=['rock', 'paper', 'scissors'], help='Choices for option example'
)

optional = my_command2.add_argument_group('Group 1')

optional.add_argument(
    '--addition',
    choices=['Spock', 'lizard'],
    help='Extra choices for additional group.',
)
optional.add_argument(
    '--lorem_ipsum',
    help='Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod '
    'tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, '
    'quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo '
    'consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse '
    'cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat '
    'non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
)