-
Notifications
You must be signed in to change notification settings - Fork 52
Update karton list command #288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -144,10 +144,20 @@ def configuration_wizard(config_filename: str) -> None: | |
| log.info("Saved the new configuration file in %s", os.path.abspath(config_filename)) | ||
|
|
||
|
|
||
| def print_bind_list(config: Config) -> None: | ||
| def print_bind_list(config: Config, short: bool) -> None: | ||
| backend = KartonBackend(config=config) | ||
| for bind in backend.get_binds(): | ||
| print(bind) | ||
|
|
||
| if short: | ||
| # Print a human-readable table-like version | ||
| print(f"{'karton name':50} {'version':10} {'karton':10}") | ||
| print("-" * 72) | ||
| for bind in backend.get_binds(): | ||
| print( | ||
| f"{bind.identity:50} {bind.service_version or "-":10} {bind.version:10}" | ||
| ) | ||
| else: | ||
| for bind in backend.get_binds(): | ||
| print(bind) | ||
|
|
||
|
|
||
| def delete_bind(config: Config, karton_name: str) -> None: | ||
|
|
@@ -180,7 +190,7 @@ def process(self, task): | |
|
|
||
| def main() -> None: | ||
|
|
||
| parser = argparse.ArgumentParser(description="Your red pill to the karton-verse") | ||
| parser = argparse.ArgumentParser(description="Karton-core management utility") | ||
| parser.add_argument("--version", action="version", version=__version__) | ||
| parser.add_argument("-c", "--config-file", help="Alternative configuration path") | ||
| parser.add_argument( | ||
|
|
@@ -189,7 +199,13 @@ def main() -> None: | |
|
|
||
| subparsers = parser.add_subparsers(dest="command", help="sub-command help") | ||
|
|
||
| subparsers.add_parser("list", help="List active karton binds") | ||
| list_parser = subparsers.add_parser("list", help="List active karton binds") | ||
| list_parser.add_argument( | ||
| "-s", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense, though in this case it's both more human readable and more machine-readable. The default format looks like this:
This suggests that maybe changing the default output format instead is a better idea (especially since the CLI is intended for humans). But it is obviously a backward incompatible change (assuming someone parses the output for some reason). For now though: I'm not sure about |
||
| "--short", | ||
| help='Print names and versions only (human readable)"', | ||
| action="store_true", | ||
| ) | ||
|
|
||
| logs_parser = subparsers.add_parser("logs", help="Start streaming logs") | ||
| logs_parser.add_argument( | ||
|
|
@@ -253,7 +269,7 @@ def main() -> None: | |
| return | ||
|
|
||
| if args.command == "list": | ||
| print_bind_list(config) | ||
| print_bind_list(config, args.short) | ||
| elif args.command == "delete": | ||
| karton_name = args.identity | ||
| print( | ||
|
|
||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe
shutil.get_terminal_size()? We can still set a max width to 72, but maybe we can set shorter padding on narrower terminal?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, maybe not worth it, 72 characters isn't very wide
------------------------------------------------------------------------