feat(config): simplify list command and add subcommand aliases
- config list: remove -l/--long option, always display URL - config list: add ls alias (already existed, kept) - config delete: add rm alias (alongside existing remove alias) - README: add config update, config list, config delete sections Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -18,6 +18,32 @@ Create remote host configuration
|
|||||||
mdrs config create neurodata https://neurodata.riken.jp/api
|
mdrs config create neurodata https://neurodata.riken.jp/api
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### config update
|
||||||
|
|
||||||
|
Update the URL of a registered remote host.
|
||||||
|
|
||||||
|
```shell
|
||||||
|
mdrs config update neurodata https://neurodata.riken.jp/api
|
||||||
|
```
|
||||||
|
|
||||||
|
### config list
|
||||||
|
|
||||||
|
List registered remote hosts.
|
||||||
|
|
||||||
|
```shell
|
||||||
|
mdrs config list
|
||||||
|
mdrs config ls
|
||||||
|
```
|
||||||
|
|
||||||
|
### config delete
|
||||||
|
|
||||||
|
Remove a registered remote host.
|
||||||
|
|
||||||
|
```shell
|
||||||
|
mdrs config delete neurodata
|
||||||
|
mdrs config rm neurodata
|
||||||
|
```
|
||||||
|
|
||||||
### login
|
### login
|
||||||
|
|
||||||
Login to remote host
|
Login to remote host
|
||||||
|
|||||||
@@ -26,10 +26,9 @@ class ConfigCommand(BaseCommand):
|
|||||||
update_parser.set_defaults(func=cls.func_update)
|
update_parser.set_defaults(func=cls.func_update)
|
||||||
# config list
|
# config list
|
||||||
list_parser = config_parsers.add_parser("list", help="list all the remote hosts", aliases=["ls"])
|
list_parser = config_parsers.add_parser("list", help="list all the remote hosts", aliases=["ls"])
|
||||||
list_parser.add_argument("-l", "--long", help="show the api url", action="store_true")
|
|
||||||
list_parser.set_defaults(func=cls.func_list)
|
list_parser.set_defaults(func=cls.func_list)
|
||||||
# config delete
|
# config delete
|
||||||
delete_parser = config_parsers.add_parser("delete", help="delete an existing remote host", aliases=["remove"])
|
delete_parser = config_parsers.add_parser("delete", help="delete an existing remote host", aliases=["remove", "rm"])
|
||||||
delete_parser.add_argument("remote", help="label of remote host")
|
delete_parser.add_argument("remote", help="label of remote host")
|
||||||
delete_parser.set_defaults(func=cls.func_delete)
|
delete_parser.set_defaults(func=cls.func_delete)
|
||||||
|
|
||||||
@@ -47,8 +46,7 @@ class ConfigCommand(BaseCommand):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def func_list(cls, args: Namespace) -> None:
|
def func_list(cls, args: Namespace) -> None:
|
||||||
is_long = bool(args.long)
|
cls.list()
|
||||||
cls.list(is_long)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def func_delete(cls, args: Namespace) -> None:
|
def func_delete(cls, args: Namespace) -> None:
|
||||||
@@ -74,13 +72,10 @@ class ConfigCommand(BaseCommand):
|
|||||||
config.url = url
|
config.url = url
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def list(cls, is_long: bool) -> None:
|
def list(cls) -> None:
|
||||||
config = ConfigFile("")
|
config = ConfigFile("")
|
||||||
for remote, url in config.list():
|
for remote, url in config.list():
|
||||||
line = f"{remote}:"
|
print(f"{remote}:\t{url}")
|
||||||
if is_long:
|
|
||||||
line += f"\t{url}"
|
|
||||||
print(line)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def delete(cls, remote: str) -> None:
|
def delete(cls, remote: str) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user