Separate partitioning from globbing in cmdutil/args package and consumers #3
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.
Changes
In the previous commit, I think that
GlobPaths
was overloaded, containing logic specific to command use-cases. This removes that functionality fromGlobPaths
and puts it back into the commands that have the special use-cases.To do this, I've introduced a new
Partition
util incmdutil/args.go
that will separate a slice into two slices given a predicate. This functionality is leveraged by both the special use-cases described above to separate the command-specific syntax from the globable filepaths.Notes
This change doesn't preserve the order of arguments in
gh gist create
. Specifically, it'll move any passed in"-"
to the end of the list of filepaths that are passed in as args. As far as I can tell, this shouldn't matter, and I've written a test to validate that hypothesis.Testing
The need for handling these special use-cases was indicated by failing unit tests. Thus, I'm using the tests as behavior validation in this PR.