Mercurial > libervia-backend
comparison libervia/cli/cmd_shell.py @ 4270:0d7bb4df2343
Reformatted code base using black.
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 19 Jun 2024 18:44:57 +0200 |
parents | 47401850dec6 |
children |
comparison
equal
deleted
inserted
replaced
4269:64a85ce8be70 | 4270:0d7bb4df2343 |
---|---|
42 | 42 |
43 | 43 |
44 class Shell(base.CommandBase, cmd.Cmd): | 44 class Shell(base.CommandBase, cmd.Cmd): |
45 def __init__(self, host): | 45 def __init__(self, host): |
46 base.CommandBase.__init__( | 46 base.CommandBase.__init__( |
47 self, host, "shell", | 47 self, host, "shell", help=_("launch libervia-cli in shell (REPL) mode") |
48 help=_("launch libervia-cli in shell (REPL) mode") | |
49 ) | 48 ) |
50 cmd.Cmd.__init__(self) | 49 cmd.Cmd.__init__(self) |
51 | 50 |
52 def parse_args(self, args): | 51 def parse_args(self, args): |
53 """parse line arguments""" | 52 """parse line arguments""" |
144 self.do_do(args) | 143 self.do_do(args) |
145 | 144 |
146 def do_help(self, args): | 145 def do_help(self, args): |
147 """show help message""" | 146 """show help message""" |
148 if not args: | 147 if not args: |
149 self.disp(A.color(C.A_HEADER, _("Shell commands:")), end=' ') | 148 self.disp(A.color(C.A_HEADER, _("Shell commands:")), end=" ") |
150 super(Shell, self).do_help(args) | 149 super(Shell, self).do_help(args) |
151 if not args: | 150 if not args: |
152 self.disp(A.color(C.A_HEADER, _("Action commands:"))) | 151 self.disp(A.color(C.A_HEADER, _("Action commands:"))) |
153 help_list = self._cur_parser.format_help().split("\n\n") | 152 help_list = self._cur_parser.format_help().split("\n\n") |
154 print(("\n\n".join(help_list[1 if self.path else 2 :]))) | 153 print(("\n\n".join(help_list[1 if self.path else 2 :]))) |
189 self.path.append(path_elt) | 188 self.path.append(path_elt) |
190 self.update_path() | 189 self.update_path() |
191 | 190 |
192 def do_version(self, args): | 191 def do_version(self, args): |
193 """show current backend/CLI version""" | 192 """show current backend/CLI version""" |
194 self.run_cmd(['--version']) | 193 self.run_cmd(["--version"]) |
195 | 194 |
196 def do_shell(self, args): | 195 def do_shell(self, args): |
197 """launch an external command (you can use ![command] too)""" | 196 """launch an external command (you can use ![command] too)""" |
198 args = self.parse_args(args) | 197 args = self.parse_args(args) |
199 self.run_cmd(args, external=True) | 198 self.run_cmd(args, external=True) |