-
Notifications
You must be signed in to change notification settings - Fork 2
Introducing Panels (MVP) #100
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
base: master
Are you sure you want to change the base?
Conversation
* add Must() wrapper for registering subcommands * add complex binary with panel constructor
Still only supports one level of subcommands (that's now more difficult than simple recursion, since the config-type for each layer is likely to be different)
Fix a couple lint nags due to capitalization of error-strings, and fix error-wrapping in a few places.
The stdlib flag package has a convenient ErrHelp type. Use that as a sentinel to short-circuit error-handling.
Consolidate the help handling a bit and make it possible for users to trigger usage printing. By moving all the usage-generation/printing into panels.help(), we get some nice consistency, and access to parent subcommands (including their flags) This now includes the root-level flags in addition to the specific subcommand requested, whether it's called as `binary help subcmd` or `binary subcmd --help` The new sentinel errors let us dump usage hints when there's a problem parsing in a subcommand (without having to figure out how to traverse back up the chain).
Tests now build & pass. Due to the constraints of table generics, we had to pull the table test loop body into its own generic function.
A lot of cases don't need to do anything with the argument-list to construct the help text, and can provide static strings. Simplify that use-case by providing an embeddable implementation that they can set string-values on.
Rather than passing an argument to NewDials that's just a FlagSource, pass a struct, so we can pass additional info as the system evolves.
Clarify some comments and rename a varialbe to make the code easier to follow.
Also, add a stub package description.
It's not worth keeping compatibility with old versions indefinitely, just bump to 1.23 so we get slices.Sorted and maps.Keys.
sergiosalvatore
left a comment
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.
A couple minor nits...
| } | ||
|
|
||
| func indentString(s string) string { | ||
| return "\t" + strings.ReplaceAll(s, "\n", "\t\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.
I think you want this to be:
| return "\t" + strings.ReplaceAll(s, "\n", "\t\n") | |
| return "\t" + strings.ReplaceAll(s, "\n", "\n\t") |
| } | ||
|
|
||
| s := p.helpString("fazzle") | ||
| t.Logf("%s", s) |
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.
We should probably have a simple assertion in here...
It's time to get panels out of an experimental branch and merge it into the main tree.
It's been languishing with only a few broken tests for a while.
For now, it only supports one level of subcommand, but that's enough for an MVP.
There are two example tools in this PR which should elucidate how to use this package.
(we should add some example tests later)