forked from daixiang0/gci
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support multiple prefixes to group them together daixiang0#107
This changes allows to use this to group multiple prefixes gci write -s standard -s default -s 'Prefix(alt.code.company.com,code.company.com)' --custom-order --skip-generated In order to provide this, a change was needed in gci --section parameter parsing The code was using pflag.StringSliceP for parsing sections. Please consider the pflag documentation: > Compared to StringArray flags, StringSlice flags take comma-separated value as arguments and split them accordingly. > For example: --ss="v1,v2" --ss="v3" While the usage of StringSliceP was legitimate with -local legacy parameter, if we consider gci documentation: > -l, --local strings put imports beginning with this string after 3rd-party packages, separate imports by comma We can assume that when gci was rewritten in its "new style", it appears it was unintended to keep using pflag.StringSliceP. Switching back to StringArrayP allows us to use comma in CLI arguments, without this change the following command would have failed: gci write -s standard -s default -s 'Prefix(alt.code.company.com,code.company.com)' --custom-order --skip-generated because pflag.StringSliceP would have considered it as: gci write -s standard -s default -s 'Prefix(alt.code.company.com' -s 'code.company.com)' --custom-order --skip-generated We can assume this change will be OK. But it will break the following command: gci write -s standard,default It was working because of StringSliceP The syntax is now gci write -s standard -s default as documented Signed-off-by: ccoVeille <3875889+ccoVeille@users.noreply.github.com>
- Loading branch information
Showing
7 changed files
with
57 additions
and
16 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
sections: | ||
- Standard | ||
- Default | ||
- Prefix(github.com/daixiang0,gitlab.com/daixiang0,daixiang0) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package main | ||
|
||
import ( | ||
"daixiang0/lib1" | ||
"fmt" | ||
"github.com/daixiang0/gci" | ||
"gitlab.com/daixiang0/gci" | ||
g "github.com/golang" | ||
"github.com/daixiang0/gci/subtest" | ||
) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
g "github.com/golang" | ||
|
||
"daixiang0/lib1" | ||
"github.com/daixiang0/gci" | ||
"github.com/daixiang0/gci/subtest" | ||
"gitlab.com/daixiang0/gci" | ||
) |
This file contains 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
This file contains 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