Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cue/cmd: ensure flags are added if they are used
Problem: trim used the dry-run flag but did not add it. This change ensures that when a value is fetched for any flag, we ensure that the flag has been added to the flagset. We panic if it has not been. Although better than the status quo, this is not quite perfect because it is only when the value is fetched at runtime that we perform this checking, and not all code paths require every flag value. So in the case of trim, if trim exits early due to some bug or divergence, then the dry-run flag value is never inspected and so we never do this checking. Trim has been fixed: it now adds the dry-run flag to the flagSet. There are quite a few cases of commands "using" flags which have not been added, much of which is because of some flags being "used" in common code (e.g. in common.go). So this change whitelists all these existing uses so that we can slowly work towards eliminating them all, and ensures the situation doesn't get worse in the mean time. Change-Id: I21263c4da9f7550e994d4bd4cbe0195f8946b2c3 Signed-off-by: Matthew Sackman <[email protected]> Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1198283 Reviewed-by: Daniel Martí <[email protected]> TryBot-Result: CUEcueckoo <[email protected]> Unity-Result: CUE porcuepine <[email protected]>
- Loading branch information