-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[VEP-4, phase 1] Flag Deprecation Warnings #9733
Conversation
go/internal/flag/flag.go
Outdated
|
||
// Second line: usage and optional default, if not the zero value | ||
// for the type. | ||
buf.WriteString(usage) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you, like me, were wondering, but what if the usage is empty? does the standard library really still print a tab character? oh boy does it!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haha good catch
go/internal/flag/flag.go
Outdated
} | ||
|
||
if strings.HasPrefix(arg, "-") { | ||
log.Warningf("Detected a positional argument beginning with a dash; this will be treated as a flag argument in the next version of Vitess. Please update your invocation to include a \"--\" before to continue treating %s as a positional argument.", arg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@deepthi let me know if you have suggestions on how to improve this warning text. i don't think it's clear, but i can't think of a way to improve it, either :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might be overthinking, but to make it clearer I would add:
include a \"--\" before to ...
-> include a \"--\" before %s to ...
with %s
being arg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this suggestion 👍
go/internal/flag/flag.go
Outdated
var buf strings.Builder | ||
goflag.CommandLine.VisitAll(func(f *goflag.Flag) { | ||
defer buf.Reset() | ||
defer func() { fmt.Fprintf(goflag.CommandLine.Output(), "%s\n", buf.String()) }() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have to wrap this defer inside an anonymous function to delay the execution of buf.String()
the other thing i briefly considered was:
defer buf.Reset()
...
if bf, ok := f.Value.(maybeBoolFlag); ok && ... {
fmt.Fprintf(...)
goto print
}
// print first and second lines for non-bool flags to `buf`
print:
fmt.Fprintf(goflag.CommandLine.Output(), "%s\n", buf.String())
but ended up deciding the goto was more gross than the defer func() { ... }()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, the defer
does not seem bad. Another alternative would be to create an anonymous function where we have the current defer
, and call that function where we return
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am excited for this VEP, phase 1 is looking good to me @ajm188 🚀
We should update the v14
/v13
docs to reflect this deprecation and how the new flags should be written.
809636e
to
7681a70
Compare
Ugh, okay this is breaking a lot of the cluster tests that check the "first line" output of vtctl because those first few lines are now all deprecation warnings ... I'm going to fix up all their invocations and see if that helps without breaking upgrade/downgrade testing. |
e506b22
to
dad50aa
Compare
🤞 🤞 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should change all the examples in the same PR. Otherwise the output will be full of warnings and difficult to parse by humans (unless you plan to fast-follow with an examples PR and want to keep PRs small and manageable).
I'm gonna DoNotMerge this, since I think there's a few more things to do, in particular:
when i finish those 3 things i'll un-DoNotMerge and ping you again. sound good? |
50fdd45
to
f76a451
Compare
This package is internal, and extremely temporary. After the necessary backwards-compatability deprecation cycle to switch to `pflag`, will be removed. Signed-off-by: Andrew Mason <andrew@planetscale.com>
…ion-aware parser Signed-off-by: Andrew Mason <andrew@planetscale.com>
Signed-off-by: Andrew Mason <andrew@planetscale.com>
…r structure Signed-off-by: Andrew Mason <andrew@planetscale.com>
Signed-off-by: Andrew Mason <andrew@planetscale.com>
…ds compatibility Signed-off-by: Andrew Mason <andrew@planetscale.com>
Signed-off-by: Andrew Mason <andrew@planetscale.com>
Signed-off-by: Andrew Mason <andrew@planetscale.com>
Signed-off-by: Andrew Mason <andrew@planetscale.com>
Signed-off-by: Andrew Mason <andrew@planetscale.com>
Signed-off-by: Andrew Mason <andrew@planetscale.com>
Signed-off-by: Andrew Mason <andrew@planetscale.com>
Alright, hold on to your butts, I'm force-pushing with what will, pending some back-and-forth on the release notes, be the final version of this change. I did all my debugging over in #9831, which I will close. |
c39304a
to
43a688e
Compare
updated all the things, this approval should in no way count (but thank you!!)
43a688e
to
dad87fc
Compare
…= v13.0.0 Signed-off-by: Andrew Mason <andrew@planetscale.com>
Signed-off-by: Andrew Mason <andrew@planetscale.com>
b886d83
to
20485b3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work!
Description
This PR introduces a helper function,
_flag.Parse
to check for the flag usages that will break when we switch toflag
. For more details, see VEP-4.The general plan here is:
_flag.Parse
withpflag.Parse
. Verify all binaries start correctly.Testing:
Here's the local example:
Related Issue(s)
vitessio/enhancements#7
Checklist
Deployment Notes