summaryrefslogtreecommitdiff
path: root/examples/option.py
blob: 73860f5442cda2e175152ea8e30b29507bff699f (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
#!/usr/bin/env python

from gi.repository import GLib

group = GLib.option.OptionGroup(
    "example", "OptionGroup Example", "Shows all example options",
    option_list=[GLib.option.make_option("--example",
                                         action="store_true",
                                         dest="example",
                                         help="An example option."),
                ])

parser = GLib.option.OptionParser(
    "NAMES ...", description="A simple gobject.option example.",
    option_list=[GLib.option.make_option("--file", "-f",
                                         type="filename",
                                         action="store",
                                         dest="file",
                                         help="A filename option"),
                 # ...
                ])

parser.add_option_group(group)

parser.parse_args()

print("group: example " + str(group.values.example))
print("parser: file " + str(parser.values.file))