Skip to content

Update karton list command#288

Merged
msm-cert merged 5 commits intomasterfrom
karton-list
Jul 28, 2025
Merged

Update karton list command#288
msm-cert merged 5 commits intomasterfrom
karton-list

Conversation

@msm-cert
Copy link
Member

No description provided.

@msm-cert msm-cert force-pushed the karton-list branch 3 times, most recently from 57e2bf2 to e2188af Compare July 24, 2025 14:16
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",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe -h for human? Similarly to du, for example

Copy link
Member Author

Choose a reason for hiding this comment

The 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:

image

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 -h since it's often used for --help. But I don't like --short either, so i've implemented this change. I used --human instead of --human-readable like in du, because in du any prefix of a valid command is accepted, so both will work.

@msm-cert
Copy link
Member Author

msm-cert commented Jul 25, 2025

Wait, I don't think this works (option -h conflicts with help indeed). Changing to draft for further discussion.

argparse.ArgumentError: argument -h/--human: conflicting option string: -h

@msm-cert msm-cert marked this pull request as draft July 25, 2025 15:25
@msm-cert
Copy link
Member Author

Changed the default instead. The following invocations were tested:

karton list -o table  # uses the new human readable format
karton list -o json  # uses jsonl
karton list  # uses table by default
karton list -o foo  # shows a helpful error message
karton list --help  # shows a helpful message and the list of options

The syntax -o table and -o json was used to be compatible with mwdb cli, which uses the same convention.

@msm-cert msm-cert marked this pull request as ready for review July 28, 2025 13:40
@msm-cert msm-cert requested a review from nazywam July 28, 2025 13:40
level = event.get("levelname")
name = event.get("name")
msg = event.get("message")
print(event)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦭

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(fixed ofc)

if output_format == "table":
# Print a human-readable table-like version
print(f"{'karton name':50} {'version':10} {'karton':10}")
print("-" * 72)
Copy link
Member

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?

Copy link
Member

@psrok1 psrok1 Jul 28, 2025

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

------------------------------------------------------------------------

@msm-cert msm-cert merged commit 3b2715b into master Jul 28, 2025
7 checks passed
@msm-cert msm-cert deleted the karton-list branch July 28, 2025 14:29
@psrok1 psrok1 mentioned this pull request Sep 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants