Skip to content

For flags controlling one behavior make the last flag take precedence #627

@not-my-profile

Description

@not-my-profile

Currently if you specify --no-gen and --gen then --no-gen always takes precedence. Same with --no-min and --min.

I have configured a shell alias scc='scc --no-cocomo --no-size --sort code' to use the flags I like by default. I am adding --no-gen because by default I want to exclude generated code but sometimes I'd still like to see it (to check if the generated files were recognized correctly). However if I add --no-gen to my shell alias then I can no longer temporarily override it by running scc --gen (I'd have to do \scc --gen which looses my other default flags or configure a separate shell alias, neither is very ergonomic.)

I looked into implementing this. scc uses cobra but the flag handling is done by pflag, a POSIX-style replacement for the stdlib flag module. It seems like this would be easiest to implement with BoolFunc, support for which has apparently been added to pflag last month ... so I think this would best wait for the next pflag release.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions