mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 10:07:14 +02:00
Handle nested subcommands
This commit is contained in:
@ -102,8 +102,14 @@ class MeasurementProtocol(TelemetryBase):
|
|||||||
self['cd5'] = caller_id.lower()
|
self['cd5'] = caller_id.lower()
|
||||||
|
|
||||||
def _prefill_screen_name(self):
|
def _prefill_screen_name(self):
|
||||||
self['cd3'] = " ".join([str(s).lower() for s in sys.argv[1:]])
|
|
||||||
|
|
||||||
|
def _first_arg_from_list(args_, list_):
|
||||||
|
for _arg in args_:
|
||||||
|
if _arg in list_:
|
||||||
|
return _arg
|
||||||
|
return None
|
||||||
|
|
||||||
|
self['cd3'] = " ".join([str(s).lower() for s in sys.argv[1:]])
|
||||||
if not app.get_session_var("command_ctx"):
|
if not app.get_session_var("command_ctx"):
|
||||||
return
|
return
|
||||||
ctx_args = app.get_session_var("command_ctx").args
|
ctx_args = app.get_session_var("command_ctx").args
|
||||||
@ -111,12 +117,25 @@ class MeasurementProtocol(TelemetryBase):
|
|||||||
if not args:
|
if not args:
|
||||||
return
|
return
|
||||||
cmd_path = args[:1]
|
cmd_path = args[:1]
|
||||||
if args[0] in ("lib", "platform", "platforms", "serialports", "device",
|
if args[0] in ("platform", "platforms", "serialports", "device",
|
||||||
"settings", "remote"):
|
"settings"):
|
||||||
cmd_path = args[:2]
|
cmd_path = args[:2]
|
||||||
if args[0] == "remote":
|
if args[0] == "lib" and len(args) > 1:
|
||||||
if len(args) > 2 and args[1] in ("agent", "device"):
|
lib_subcmds = ("install", "list", "register", "search", "show",
|
||||||
cmd_path = args[:3]
|
"uninstall", "update")
|
||||||
|
sub_cmd = _first_arg_from_list(args[1:], lib_subcmds)
|
||||||
|
if sub_cmd:
|
||||||
|
cmd_path.append(sub_cmd)
|
||||||
|
elif args[0] == "remote" and len(args) > 1:
|
||||||
|
remote_subcmds = ("agent", "device", "run", "test")
|
||||||
|
sub_cmd = _first_arg_from_list(args[1:], remote_subcmds)
|
||||||
|
if sub_cmd:
|
||||||
|
cmd_path.append(sub_cmd)
|
||||||
|
if len(args) > 2 and sub_cmd in ("agent", "device"):
|
||||||
|
remote2_subcmds = ("list", "start", "monitor")
|
||||||
|
sub_cmd = _first_arg_from_list(args[2:], remote2_subcmds)
|
||||||
|
if sub_cmd:
|
||||||
|
cmd_path.append(sub_cmd)
|
||||||
self['screen_name'] = " ".join([p.title() for p in cmd_path])
|
self['screen_name'] = " ".join([p.title() for p in cmd_path])
|
||||||
|
|
||||||
def send(self, hittype):
|
def send(self, hittype):
|
||||||
|
Reference in New Issue
Block a user