-
Notifications
You must be signed in to change notification settings - Fork 105
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
warn when a positional argument might have been a flag #1147
warn when a positional argument might have been a flag #1147
Conversation
Signed-off-by: Joe Kimmel <jkimmel@vmware.com>
@@ -57,6 +57,12 @@ func Run(c Command, withPhaseName string, asSubcommand bool) { | |||
} | |||
cmd.DefaultLogger.Debugf("Starting %s...", withPhaseName) | |||
|
|||
for _, arg := range flagSet.Args() { | |||
if arg[0:1] == "-" { | |||
cmd.DefaultLogger.Warnf("Warning: unconsumed flag-like positional arg: \n\t%s\n\t This will not be interpreted as a flag.\n\t Did you mean to put this before the first 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.
Oh, this was already merged, but I think we could remove the Warning:
because we are using Warnf
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.
ah yeah... @jjbustamante you're right - it's a "Warning: Warning: " 😅 maybe we say it extra to make up for all the years we were silent about it???
Signed-off-by: Joe Kimmel <jkimmel@vmware.com>
Signed-off-by: Joe Kimmel <jkimmel@vmware.com>
* restorer gets layers flag again Signed-off-by: Joe Kimmel <jkimmel@vmware.com> * add explanatory debug logs so a reader knows why the buildpacks are read twice. Signed-off-by: Joe Kimmel <jkimmel@vmware.com> * warn when a positional argument might have been a flag (#1147) Signed-off-by: Joe Kimmel <jkimmel@vmware.com> * Add test for empty digest not returned Signed-off-by: Natalie Arellano <narellano@vmware.com> * Fix acceptance by providing a base image when we instantiate the remote run image Signed-off-by: Natalie Arellano <narellano@vmware.com> * timestamp logs and phase error message cherry-picks (#1164) * timestamp logs for entry/exit for all the top-level Lifecycle package functions Signed-off-by: Joe Kimmel <jkimmel@vmware.com> fixing names Signed-off-by: Joe Kimmel <jkimmel@vmware.com> using defer to make one-liners for fun and profit Signed-off-by: Joe Kimmel <jkimmel@vmware.com> and today we thank our brave linters for preventing critical defects such as unnecessary trailing newlines from being merged. Its about time somebody thought of the children. Signed-off-by: Joe Kimmel <jkimmel@vmware.com> * be more helpful when you dont recognize the phase Signed-off-by: Joe Kimmel <jkimmel@vmware.com> --------- Signed-off-by: Joe Kimmel <jkimmel@vmware.com> * Simplifies target matching logic per spec PR review (#1166) * Update units without updating code Signed-off-by: Natalie Arellano <narellano@vmware.com> * Update code Signed-off-by: Natalie Arellano <narellano@vmware.com> * Unpend test Signed-off-by: Natalie Arellano <narellano@vmware.com> * Add units for rebase without updating code Signed-off-by: Natalie Arellano <narellano@vmware.com> * Update rebase code Signed-off-by: Natalie Arellano <narellano@vmware.com> * Fix lint Signed-off-by: Natalie Arellano <narellano@vmware.com> * When we read the descriptor file, don't fill in "*" as a magic value as missing values are wildcard matches Signed-off-by: Natalie Arellano <narellano@vmware.com> * Stricter validation for rebase Signed-off-by: Natalie Arellano <narellano@vmware.com> --------- Signed-off-by: Natalie Arellano <narellano@vmware.com> * Add -daemon to restorer (#1168) This is needed when extensions were used to switch (but not extend) the run image and we need to re-read the target data from the image config. In such cases, we don't need the run image to exist in a registry, because we don't need a manifest for kaniko. Signed-off-by: Natalie Arellano <narellano@vmware.com> * Remove CNB_TARGET_ID according to buildpacks/spec#374 and buildpacks/spec#375 (#1175) Signed-off-by: Natalie Arellano <narellano@vmware.com> * Field renames per spec review (#1170) * Rename distributions -> distros in the buildpack spec Signed-off-by: Natalie Arellano <narellano@vmware.com> * Rename distributions -> distros in the platform spec Signed-off-by: Natalie Arellano <narellano@vmware.com> --------- Signed-off-by: Natalie Arellano <narellano@vmware.com> * force pack acceptance tests to build with a version of go that can still make HTTP requests to docker daemon (#1158) Signed-off-by: Joe Kimmel <jkimmel@vmware.com> --------- Signed-off-by: Joe Kimmel <jkimmel@vmware.com> Signed-off-by: Natalie Arellano <narellano@vmware.com> Co-authored-by: Joe Kimmel <jkimmel@vmware.com> Co-authored-by: Joe Kimmel <86852107+joe-kimmel-vmw@users.noreply.github.com>
I was tempted to make it a fatal error and exit but honestly someone out there probably has an app called
-minuses-are-cool-characters-to-start-my-app-name-with
or something.before
would result in a bunch of reasonable looking output but end with:
because we put the
-launcher
flag after the app name.NOTE that this is much harder to notice if there's several other args, especially if the app-name positional arg is preceded by a boolean flag arg such as
-daemon
.after
Your stuff will still fail, but there'll be a big warning message towards the top saying something like