-
Notifications
You must be signed in to change notification settings - Fork 42
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
Use YAML for CLI command generation #666
Conversation
the new format does not allow enum options for a |
temporalcli/commandsmd/commands.yml
Outdated
- name: raw | ||
type: bool | ||
description: Print properties without changing their format. | ||
default: true |
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.
Description for this option used to be
* `--raw` (bool) -
Print properties without changing their format.
Defaults to true.
Which states defaults to true
, but the code didn't seem to support that. Should this be removed from the description? A bool that defaults to true feels weird/doesn't make sense.
temporalcli/commands.gen.go
Outdated
s.Command.Flags().StringVar(&s.Description, "description", "", "Endpoint description in markdown format (encoded using the configured codec server).") | ||
s.Command.Flags().StringVar(&s.DescriptionFile, "description-file", "", "Endpoint description file in markdown format (encoded using the configured codec server).") | ||
s.Command.Flags().StringVar(&s.Description, "description", "", "Endpoint description in markdown format (encoded using the configured codec server).\n") | ||
s.Command.Flags().StringVar(&s.DescriptionFile, "description-file", "", "Endpoint description file in markdown format (encoded using the configured codec server).\n") |
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.
Same question as above—with options, I would expect this to be more of a problem, since it might mess up the formatting/spacing of options if some have a trailing \n
and some don't.
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.
good point, I've removed all \n
from the options, generated output should match previous markdown formatting
15a7549
to
ee16399
Compare
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.
I'll be honest that I didn't read the parser/generator changes super closely; I mostly looked at the generated output, which seems good to me. There's only one small comment about the log-format
flag that's not a blocker for merging IMO. Otherwise LGTM!
s.Command.PersistentFlags().StringVar(&s.LogFormat, "log-format", "", "Log format. Options are: text, json. Defaults to: text.") | ||
s.Command.PersistentFlags().StringVar(&s.LogFormat, "log-format", "text", "Log format. Options are: text, json.") |
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.
There was some reason we didn't want the default to be programmatically-encoded that I can't remember. Can you double-check this and make sure it's not changing behavior somehow?
Actually, one other thought: let's wait for @cretz to take a look before merging in case he spots something I didn't. |
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.
This looks great and basically exactly how I would have done it. Only comment worth noting is the request to change the package/dir name, everything else is non-blocking. Don't forget to update CONTRIBUTING.md
.
temporalcli/commandsmd/commands.yml
Outdated
Log level. | ||
Default is "info" for most commands and "warn" for `server start-dev`. |
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.
Are we expected to retain the one-sentence-per-line approach? If so, how come done in options description but not command description? (do not need to fix, more for general discussion)
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.
No, I want to get rid of this eventually and use a proper Markdown renderer for both the description and flags. The reason it was needed for flags is because newlines show up in the generated output, so having newlines inserted in (to-the-user) random places really doesn't look good. I think Andrew has since fixed this? In which case I have no opinion.
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.
I think we should have a general/consistent rule for Markdown description
. Right now it seems a bit inconsistent.
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.
Agree, eventually; we can make this consistent once we have a proper Markdown formatter IMO.
temporalcli/commandsmd/commands.yml
Outdated
type: string | ||
description: | | ||
Log format. | ||
Options are: text, json. |
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.
There are more options than this, but I know this is a docs problem. No need to fix, can ignore. Henceforth in this PR I won't be commenting on things that are already a problem in main
.
temporalcli/commandsgen/parse.go
Outdated
@@ -0,0 +1,192 @@ | |||
// Package commandsgen is built to read the markdown format described in | |||
// temporalcli/commands.md and generate code from it. |
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.
This statement is not accurate anymore
Makefile
Outdated
@@ -4,7 +4,7 @@ all: gen build | |||
|
|||
gen: temporalcli/commands.gen.go | |||
|
|||
temporalcli/commands.gen.go: temporalcli/commandsmd/commands.md | |||
temporalcli/commands.gen.go: temporalcli/commandsgen/commands.md |
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.
This still references commands.md
. In a perfect world this would have failed CI with something like:
No rule to make target 'temporalcli/commandsgen/commands.md', needed by 'temporalcli/commands.gen.go'
But unfortunately this Makefile is an untested/undocumented thing just sitting in the repo
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.
oops, thanks for catching this!
What was changed
Moved from Markdown to YAML for CLI command generation.
This switch also fixes a bug where option set aliases weren't being persisted to commands that use them (i.e.
NewTemporalScheduleCreateCommand
)Why?
More standardized format, easier to parse and add to
Checklist
Closes Switch to a common format for CLI command generation #620
How was this tested:
Passes all CI tests