Closed nicolasparada closed 1 year ago
If you're merely renaming the flag, you can share the Value
between two different flags:
fs.Bool("new", false, "new flag usage")
newFlag := fs.Lookup("new")
// deprecated --old alias for --new
oldFlag := fs.VarPF(newFlag.Value, "old", "", "old flag usage")
oldFlag.Deprecated = "use --new"
oldFlag.Hidden = true
// only necessary when newFlag.NoOptDefVal != "", like if --new is a bool flag
oldFlag.NoOptDefVal = newFlag.NoOptDefVal
That's what I did at the end.
Maybe the docs are a little bit confusing in the readme.
I want to rename a flag. Mark the old one as deprecated but allow it to keep working. Basically add an alias.
I tried normalizing it to add the alias.
But now if I deprecate the old flag, it also deprecates the new one. Like if they were connected.
Btw, marking it as hidden, also hides both.
I tried changing the order of stuff but didn't work. For now I removed the normalize function and got a similar result to what I want. But this behavior is a little unexpected.