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.
Motivation
Partly fixes #790
While the issue primarily talks about the inconsistent behavior of the
StringSliceFlag
, there is another bug report hidden there. Consider the following code:Suppose we are to execute this code using either
--Hostnames
or-n
, we would expect both thec.IsSet("Hostnames")
andc.IsSet("n")
to returntrue
. However, this is not the case. If we use the full flag name to initialize the flag but, pass the short name toc.IsSet
, we get false.This behavior is also inconsistent with the
c.StringSlice
or anyc.FlagName
function that returns the correct value regardless of whether we pass the full name or the short name to it. This PR aims to fix this inconsistency.Release Notes
[BUG FIX]
context.IsSet()
returnstrue
orfalse
correctly regardless of whether the short name or the full name of the flag is passed to it.Changes
.gitignore
: Add.idea
folder to list of ignored files. JetBrains IDEs like GoLand create this folder.context.go
: Add additional code that checks if a particular flag is set and, if set, marks all the other aliases of the flag in the context.context_test.go
: Test CasesTesting
Added a unit test that sets the flags using both full names and short names alternatively and verifies the consistency of the
context.IsSet
output.