Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: support multiple prefixes #142

Merged
merged 1 commit into from
Mar 2, 2023

Commits on Mar 1, 2023

  1. 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>
    ccoVeille committed Mar 1, 2023
    Configuration menu
    Copy the full SHA
    72599ab View commit details
    Browse the repository at this point in the history