Open
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.
Contributor
sergiosalvatore
left a comment
There was a problem hiding this comment.
A couple minor nits...
| } | ||
|
|
||
| func indentString(s string) string { | ||
| return "\t" + strings.ReplaceAll(s, "\n", "\t\n") |
Contributor
There was a problem hiding this comment.
I think you want this to be:
Suggested change
| return "\t" + strings.ReplaceAll(s, "\n", "\t\n") | |
| return "\t" + strings.ReplaceAll(s, "\n", "\n\t") |
| } | ||
|
|
||
| s := p.helpString("fazzle") | ||
| t.Logf("%s", s) |
Contributor
There was a problem hiding this comment.
We should probably have a simple assertion in here...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)