]>
glassweightruler.freedombox.rocks Git - waydroid.git/blob - tools/helpers/arguments.py
1 # Copyright 2021 Oliver Smith
2 # SPDX-License-Identifier: GPL-3.0-or-later
12 """ This file is about parsing command line arguments passed to waydroid, as
13 well as generating the help pages (waydroid -h). All this is done with
14 Python's argparse. The parsed arguments get extended and finally stored in
15 the "args" variable, which is prominently passed to most functions all
16 over the waydroid code base.
18 See tools/helpers/args.py for more information about the args variable. """
20 def arguments_init(subparser
):
21 ret
= subparser
.add_parser("init", help="set up waydroid specific"
22 " configs and install images")
23 ret
.add_argument("-i", "--images_path",
24 help="custom path to waydroid images (default in"
25 " /var/lib/waydroid/images)")
26 ret
.add_argument("-f", "--force", action
="store_true",
27 help="re-initialize configs and images")
28 ret
.add_argument("-c", "--system_channel",
29 help="custom system channel (options: OTA channel URL; default is Official OTA server)")
30 ret
.add_argument("-v", "--vendor_channel",
31 help="custom vendor channel (options: OTA channel URL; default is Official OTA server)")
32 ret
.add_argument("-r", "--rom_type",
33 help="rom type (options: \"lineage\", \"bliss\" or OTA channel URL; default is LineageOS)")
34 ret
.add_argument("-s", "--system_type",
35 help="system type (options: VANILLA, FOSS or GAPPS; default is VANILLA)")
36 ret
.add_argument("-g", "--gui", action
="store_true",
37 help="run as a graphical interface")
40 def arguments_status(subparser
):
41 ret
= subparser
.add_parser("status",
42 help="quick check for the waydroid")
45 def arguments_upgrade(subparser
):
46 ret
= subparser
.add_parser("upgrade", help="upgrade images")
47 ret
.add_argument("-o", "--offline", action
="store_true",
48 help="just for updating configs")
51 def arguments_log(subparser
):
52 ret
= subparser
.add_parser("log", help="follow the waydroid logfile")
53 ret
.add_argument("-n", "--lines", default
="60",
54 help="count of initial output lines")
55 ret
.add_argument("-c", "--clear", help="clear the log",
56 action
="store_true", dest
="clear_log")
59 def arguments_session(subparser
):
60 ret
= subparser
.add_parser("session", help="session controller")
61 sub
= ret
.add_subparsers(title
="subaction", dest
="subaction")
62 sub
.add_parser("start", help="start session")
63 sub
.add_parser("stop", help="start session")
66 def arguments_container(subparser
):
67 ret
= subparser
.add_parser("container", help="container controller")
68 sub
= ret
.add_subparsers(title
="subaction", dest
="subaction")
69 sub
.add_parser("start", help="start container")
70 sub
.add_parser("stop", help="stop container")
71 sub
.add_parser("restart", help="restart container")
72 sub
.add_parser("freeze", help="freeze container")
73 sub
.add_parser("unfreeze", help="unfreeze container")
76 def arguments_app(subparser
):
77 ret
= subparser
.add_parser("app", help="applications controller")
78 sub
= ret
.add_subparsers(title
="subaction", dest
="subaction")
79 install
= sub
.add_parser(
80 "install", help="push a single package to the container and install it")
81 install
.add_argument('PACKAGE', help="path to apk file")
82 remove
= sub
.add_parser(
83 "remove", help="remove single app package from the container")
84 remove
.add_argument('PACKAGE', help="package name of app to remove")
85 launch
= sub
.add_parser("launch", help="start single application")
86 launch
.add_argument('PACKAGE', help="package name of app to launch")
87 intent
= sub
.add_parser("intent", help="start single application")
88 intent
.add_argument('ACTION', help="action name")
89 intent
.add_argument('URI', help="data uri")
90 sub
.add_parser("list", help="list installed applications")
93 def arguments_prop(subparser
):
94 ret
= subparser
.add_parser("prop", help="android properties controller")
95 sub
= ret
.add_subparsers(title
="subaction", dest
="subaction")
97 "get", help="get value of property from container")
98 get
.add_argument('key', help="key of the property to get")
100 "set", help="set value to property on container")
101 set.add_argument('key', help="key of the property to set")
102 set.add_argument('value', help="value of the property to set")
105 def arguments_fullUI(subparser
):
106 ret
= subparser
.add_parser("show-full-ui", help="show android full screen in window")
109 def arguments_firstLaunch(subparser
):
110 ret
= subparser
.add_parser("first-launch", help="initialize waydroid and start it")
113 def arguments_shell(subparser
):
114 ret
= subparser
.add_parser("shell", help="run remote shell command")
115 ret
.add_argument('COMMAND', nargs
='?', help="command to run")
118 def arguments_logcat(subparser
):
119 ret
= subparser
.add_parser("logcat", help="show android logcat")
123 parser
= argparse
.ArgumentParser(prog
="waydroid")
126 parser
.add_argument("-V", "--version", action
="version",
127 version
=tools
.config
.version
)
130 parser
.add_argument("-l", "--log", dest
="log", default
=None,
131 help="path to log file")
132 parser
.add_argument("--details-to-stdout", dest
="details_to_stdout",
133 help="print details (e.g. build output) to stdout,"
134 " instead of writing to the log",
136 parser
.add_argument("-v", "--verbose", dest
="verbose",
137 action
="store_true", help="write even more to the"
138 " logfiles (this may reduce performance)")
139 parser
.add_argument("-q", "--quiet", dest
="quiet", action
="store_true",
140 help="do not output any log messages")
141 parser
.add_argument("-w", "--wait", dest
="wait_for_init", action
="store_true",
142 help="wait for init before running")
145 sub
= parser
.add_subparsers(title
="action", dest
="action")
147 arguments_status(sub
)
150 arguments_upgrade(sub
)
151 arguments_session(sub
)
152 arguments_container(sub
)
155 arguments_fullUI(sub
)
156 arguments_firstLaunch(sub
)
158 arguments_logcat(sub
)
161 argcomplete
.autocomplete(parser
, always_complete_options
="long")
163 # Parse and extend arguments (also backup unmodified result from argparse)
164 args
= parser
.parse_args()