src/eric7/WebBrowser/WebBrowserArgumentsCreator.py

branch
eric7
changeset 10308
d19766190e17
child 10439
21c28b0f9e41
equal deleted inserted replaced
10307:c685f4e12916 10308:d19766190e17
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2023 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a function to create an argparse.Namespace object for the web
8 browser.
9 """
10
11 import argparse
12 import sys
13
14
15 def createArgparseNamespace(argv=None):
16 """
17 Function to create an argparse.Namespace object.
18
19 @param argv list of command line arguments to be parsed
20 @type list of str
21 @return created argument parser object
22 @rtype argparse.ArgumentParser
23 """
24 from eric7.UI.Info import Version
25
26 # 1. create the argument parser
27 parser = argparse.ArgumentParser(
28 description="Web Browser application of the eric tool suite.",
29 epilog="Copyright (c) 2002 - 2023 Detlev Offenbach <detlev@die-offenbachs.de>.",
30 )
31
32 # 2. add the arguments
33 parser.add_argument(
34 "-V",
35 "--version",
36 action="version",
37 version="%(prog)s {0}".format(Version),
38 help="show version information and exit",
39 )
40 parser.add_argument(
41 "--config",
42 metavar="config_dir",
43 help="use the given directory as the one containing the config files",
44 )
45 parser.add_argument(
46 "--settings",
47 metavar="settings_dir",
48 help="use the given directory to store the settings files",
49 )
50 parser.add_argument(
51 "--name",
52 metavar="browser name",
53 default="",
54 help="name to be used for the browser instance",
55 )
56 parser.add_argument(
57 "--new-tab",
58 metavar="URL",
59 action="append",
60 help="open a new tab for the given URL",
61 )
62 parser.add_argument(
63 "--private",
64 action="store_true",
65 help="start the browser in private browsing mode",
66 )
67 parser.add_argument(
68 "--qthelp",
69 action="store_true",
70 help="start the browser with support for QtHelp",
71 )
72 parser.add_argument(
73 "--quiet",
74 action="store_true",
75 help="don't show any startup error messages",
76 )
77 parser.add_argument(
78 "--search",
79 metavar="searchword",
80 help="search for the given word",
81 )
82 parser.add_argument(
83 "--shutdown",
84 action="store_true",
85 help="shut down the browser instance",
86 )
87 parser.add_argument(
88 "--single",
89 action="store_true",
90 help="start the browser as a single application",
91 )
92 parser.add_argument(
93 "home",
94 nargs="?",
95 default="",
96 metavar="file | URL",
97 help="open a file or URL",
98 )
99
100 # 3. create the Namespace object by parsing the command line
101 if argv is None:
102 argv = sys.argv[1:]
103 args = parser.parse_args(argv)
104 return args

eric ide

mercurial