All notable changes to this project will be documented in this file. The format is based on Keep a Changelog.
Note that I update this changelog as I make changes, so the top version (right below this description) is likely unreleased.
- Moved
SetBy
into theValue
interface (value.UpdatedBy()
- this allowsFlag
to be readonly and and makes the coupling between setting the value and updatingUpdatedBy
explicit - Flags must now be the last things passed - i.e.
<appname> <section> <command> <flag>...
. In addition, the only flag allowed after a<section>
is the--help
flag (unfortunately the--color
flag is NOT currently allowed to be passed for section help). This simplifies the parsing and will help with tab completion, and after that's implemented I might try to restore the old behavior if I get too annoyed with this limitation. Temporarily, the old behavior can be restored by setting theWARG_PRE_V0_0_26_PARSE_ALGORITHM
environment variable, but I plan to remove that in the next version.
Examples:
$ go run ./examples/butler --color false -h
Parse err: Parse args error: expecting section or command, got --color
exit status 64
$ WARG_PRE_V0_0_26_PARSE_ALGORITHM=1 go run ./examples/butler --color false -h
A virtual assistant
# ... more text ...
path.Path
type that users should callExpand
/MustExpand
on. SeeRemoved
- The signature of
value.EmptyConstructor
no longer has the opportunity to return an error. I don't think anything ever returned an error, so this was never needed.
- Removed
value.FromInstance
. This is a nasty silent breaking change because it'll break users at runtime (not compile time) when they updatewarg
. However,value.FromInstance
was only used for expanding~
inPath
's from default values - no other value types needed it. It also wasn't really testable since the value~
expanded to is different per machine (without env var shennanigans). I'm replacing it with aPath
type that the user is expected to callPath
/MustExpand
on.
Old:
path := cmdCtx.Flags["--mypath"].(string)
New:
path := cmdCtx.Flags["--mypath"].(path.Path).MustExpand()
This is the start of some big changes to warg
. I'm doing this mostly to make
adding tab completion a lot easier, but also because I've spent a few years
with warg
now and I think I can simplify a few things.
I'm making sure all the tests pass, but I'm making enough changes to enough code I no longer remember the exact context for that I'm sure I'll have to make some bugfix releases. I think this is acceptable because I'm the only user of this library and I think it'll be faster overall with my limited time and energy.
I'm marking each breaking change with a new version so I can update piecemeal or all at once.
- Removed section flags in favor of app global flags. This is strictly less flexible than section flags, but paves the way to building easier tab completion, and it's easy use existing flags in multiple commands if they don't need to be global.
- make
warg.GoldenTest
useGoldenTestArgs
andParseOpt
s
- make
warg.GoldenTest
acceptParseOpt
s instead of a hardcoded list of options
command.Context
:Version
,AppName
,Path
fields. Justification: I want to pass these fields to OpenTelemetry instarghaze
.command.Context.Context
field: Justification: I want to smuggle mocks into mycommand.Action
s when testing. Before, this, I added an ugly "mock selection" flag, and this is much cleaner.
- move
warg.ParseResult.Path
tocommand.Context.Path
. - rm
warg.AddVersionCommand()
in favor ofwarg.VersionCommand()
. Use withsection.ExistingCommand("version", warg.VersionCommand()),
. Justification: more declarative - I'd like to define all commands inside the root section instead of having another way to add a flag as a warg option. - rm
warg.AddColorFlag()
in favor ofwarg.ColorFlag()
. Use withsection.ExistingFlag("--color", warg.ColorFlag()),
. Same justification aswarg.VersionCommand()
. - update
Parse()
to useParseOpt
s instead of positional args:OverrideArgs
,OverrideLookupFunc
. Justification: these have obvious defaults that only need overriding for tests, which also probably want to use otherParseOpt
s. - move
warg.OverrideStderr
andwarg.OverrideStdout
to beParseOpt
s instead ofAppOpt
s. Justification: This removes the need for these public fields inApp
and nicer for callers.
- Fix YAML config parsing for
value.Dict
- Fix panic when using a
value.Dict
and callingdetailed.DetailedCommandHelp
contained.Addr
andcontained.AddrPort
flag.UnsetSentinel
to allow for unsetting flagsvalue.Dict
containerwarg.GoldenTest