Thanks to visit codestin.com
Credit goes to github.com

Skip to content

docs: Add CLI docs #5879

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

Merged
merged 15 commits into from
Jan 27, 2023
Merged

docs: Add CLI docs #5879

merged 15 commits into from
Jan 27, 2023

Conversation

BrunoQuaresma
Copy link
Collaborator

Add auto-generated docs for CLI

@BrunoQuaresma BrunoQuaresma requested a review from mtojek January 26, 2023 17:59
@BrunoQuaresma BrunoQuaresma self-assigned this Jan 26, 2023
Copy link
Member

@kylecarbs kylecarbs left a comment

Choose a reason for hiding this comment

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

Preview: https://coder.com/docs/v2/6b5f959/cli/coder

We should change the icon so it's not the same as API. We'll also have to strip the weird ANSI sequences.

@BrunoQuaresma
Copy link
Collaborator Author

Also found a new issue:
Screen Shot 2023-01-26 at 15 51 09

@kylecarbs Do you know if it is going to happen for prod as well?

@BrunoQuaresma
Copy link
Collaborator Author

It is not showing the options in a good way, but I think it is an issue in the code on the docs website. I'm going to fix/improve it as soon as this gets merged.

@BrunoQuaresma
Copy link
Collaborator Author

BrunoQuaresma commented Jan 26, 2023

I'm also getting an error in the fmt check:

-                              Consumes $CODER_CONFIG_DIR (default "/home/coder/.config/coderv2")
+                              Consumes $CODER_CONFIG_DIR (default "/home/runner/.config/coderv2")

Looks like the command description is a bit different from what is generated. For scenarios like these, I'm thinking on use an env var called CLI_ENV and check if its value is docs, if it is docs, the default value helper should not be added. Thoughts?

Copy link
Member

@mtojek mtojek left a comment

Choose a reason for hiding this comment

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

Looks like the command description is a bit different from what is generated. For scenarios like these, I'm thinking on use an env var called CLI_ENV and check if its value is docs, if it is docs, the default value helper should not be added. Thoughts?

It's more like a hack, but should do its work 👍 .

@BrunoQuaresma
Copy link
Collaborator Author

It's more like a hack, but should do its work 👍 .

I think would be interesting to inject this value into the CLI but I'm not sure how to make it using Go and the current library. If I would make it using JS it would look like this:

const ci = new CI({ defaultConfigDir: "..." })

Thoughts?

@mtojek
Copy link
Member

mtojek commented Jan 27, 2023

Thoughts?

You can take a look at the TestCommandHelp, which overwrites defaults. There is t.Setenv (or os.Setenv), that can set the environment variable.

@BrunoQuaresma BrunoQuaresma requested a review from mtojek January 27, 2023 14:03
Copy link
Member

@mtojek mtojek left a comment

Choose a reason for hiding this comment

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

👍

Left 2 nitpicks, but this is in a good shape to merge.

// Remove non printable strings from generated markdown
// https://github.com/spf13/cobra/issues/1878
const ansi = "[\u001B\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\u0007)|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"
ansiRegex := regexp.MustCompile(ansi)
Copy link
Member

Choose a reason for hiding this comment

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

nit: Oh, I meant, top top, for instance, line 29.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ahhh, I see. But I think would be better to have them together since they are only used here. It makes it easier to reason about IMO but no strong opinions.

@BrunoQuaresma BrunoQuaresma enabled auto-merge (squash) January 27, 2023 17:16
@BrunoQuaresma BrunoQuaresma merged commit e0d48e7 into main Jan 27, 2023
@BrunoQuaresma BrunoQuaresma deleted the bq/add-cli-docs branch January 27, 2023 18:10
@github-actions github-actions bot locked and limited conversation to collaborators Jan 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants