Skip to content

Enhance CLI command formatting and fix section name parsing - #184

Open
sadesguy wants to merge 6 commits into
opsmate-ai:mainfrom
sadesguy:fix/help_formatting
Open

Enhance CLI command formatting and fix section name parsing#184
sadesguy wants to merge 6 commits into
opsmate-ai:mainfrom
sadesguy:fix/help_formatting

Conversation

@sadesguy

@sadesguy sadesguy commented May 3, 2025

Copy link
Copy Markdown

Refactor the CLI command structure to utilize a custom help formatter, improving the display of command help. Fixes issues with section name parsing in the help formatter for better clarity.

@jingkaihe

jingkaihe commented May 3, 2025

Copy link
Copy Markdown
Member

Hi, again thanks for looking into improving the help doc based on our discussion. I just checked it out, and gave it try. It looks very impressive! Will give it detailed review later today.

So far this is my initial feedback:

  • Can you leave the default options as it is as it is something useful to know?
  • I really like the cli colours, but at the same time I'd prefer not having it, as all the the cli I use do not have colours in the options, and I'd prefer sticking to the convention.

@sadesguy

sadesguy commented May 4, 2025

Copy link
Copy Markdown
Author
  • Can you leave the default options as it is as it is something useful to know?

can you elaborate?

I’ve created a "—no-color" flag (true by default) with OPSMATE_COLOR env var if users want to use colors

@jingkaihe

Copy link
Copy Markdown
Member

@sadesguy e.g.

  -c, --context TEXT
      The context to use for the session. Run `opsmate list-contexts` to see the available
contexts. (env: OPSMATE_CONTEXT)

vs

  -c, --context TEXT              The context to use for the session. Run
                                  `opsmate list-contexts` to see the available
                                  contexts. (env: OPSMATE_CONTEXT)  [default:
                                  cli]

^ the existing behaviour where there is a [default: cli] that suggests the default option

Comment thread opsmate/contexts/docker.py Outdated
@@ -0,0 +1,124 @@
from opsmate.tools import (

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I like the implementation of docker context.

that being said can you raise it in a separate PR to avoid scope creeping (as this irrelevant to the help formatting?

Comment thread Dockerfile
COPY --from=builder /app/dist/opsmate-*.whl /tmp/dist/

RUN pip install --no-cache-dir /tmp/dist/opsmate-*.whl && opsmate version
RUN --mount=type=cache,target=/root/.cache/pip \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

TIL mount cache! 👍

Comment thread opsmate/cli/cli.py Outdated
Comment thread opsmate/cli/formatting.py
@@ -0,0 +1,530 @@
import click

@jingkaihe jingkaihe May 6, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I gave this a thought. I'm impressed by the format, but have to say I prefer the orthodox name ... description format for the --help option

for example the docker one:

docker ps --help
Usage:  docker ps [OPTIONS]

List containers

Aliases:
  docker container ls, docker container list, docker container ps, docker ps

Options:
  -a, --all             Show all containers (default shows just running)
  -f, --filter filter   Filter output based on conditions provided
      --format string   Format output using a custom template:
                        'table':            Print output in table format with column headers (default)
                        'table TEMPLATE':   Print output in table format using the given Go template
                        'json':             Print in JSON format
...

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I gave this a thought. Have to say I prefer the orthodox name ... description format for the --help option

for example the docker one:

docker ps --help
Usage:  docker ps [OPTIONS]

List containers

Aliases:
  docker container ls, docker container list, docker container ps, docker ps

Options:
  -a, --all             Show all containers (default shows just running)
  -f, --filter filter   Filter output based on conditions provided
      --format string   Format output using a custom template:
                        'table':            Print output in table format with column headers (default)
                        'table TEMPLATE':   Print output in table format using the given Go template
                        'json':             Print in JSON format
...

Don’t you think it will be a little cramped with all of the description each option has? For me it hits a little on my eyes with all of the text

…er-related problem solving, sloght dockerfile improvement
@sadesguy
sadesguy force-pushed the fix/help_formatting branch from 1050e02 to bda05d9 Compare May 6, 2025 16:51
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.

2 participants