This repository was archived by the owner on Jul 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 55
Consistent help behavior #139
Open
dspalmer99
wants to merge
19
commits into
anchore:master
Choose a base branch
from
dspalmer99:issue-128
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a9de1ba to
297af33
Compare
…s run lazily. Signed-off-by: Daniel Palmer <dan.palmer@anchore.com>
… api auth. Signed-off-by: Daniel Palmer <dan.palmer@anchore.com>
Signed-off-by: Daniel Palmer <dan.palmer@anchore.com>
Signed-off-by: Daniel Palmer <dan.palmer@anchore.com>
…m context. Signed-off-by: Daniel Palmer <dan.palmer@anchore.com>
Signed-off-by: Daniel Palmer <dan.palmer@anchore.com>
Signed-off-by: Daniel Palmer <dan.palmer@anchore.com>
Signed-off-by: Daniel Palmer <dan.palmer@anchore.com>
Signed-off-by: Daniel Palmer <dan.palmer@anchore.com>
Signed-off-by: Daniel Palmer <dan.palmer@anchore.com>
Signed-off-by: Daniel Palmer <dan.palmer@anchore.com>
Signed-off-by: Daniel Palmer <dan.palmer@anchore.com>
Signed-off-by: Daniel Palmer <dan.palmer@anchore.com>
Signed-off-by: Daniel Palmer <dan.palmer@anchore.com>
Signed-off-by: Daniel Palmer <dan.palmer@anchore.com>
Signed-off-by: Daniel Palmer <dan.palmer@anchore.com>
Signed-off-by: Daniel Palmer <dan.palmer@anchore.com>
Signed-off-by: Daniel Palmer <dan.palmer@anchore.com>
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #128
Fixes #26
This moves execution of the parent/group functions over any given sub-command into callbacks to be executed by the specifically-called subcommand. This has the effect of making any code in the parent/group function lazily executed. This allows --help to be called on any given command, even if the system is not up or cannot otherwise be connected to. This was not possible without this change because the parent/group commands typically have auth code that would be executed and, in cases where it failed, block the execution of the downstream subcommand with the --help flag.
To illustrate this, consider the commands
anchore-cli image -handanchore-cli image list -h. These commands should display the help text forimageandlist(the latter being a subcommand under theimagegroup), even if the cli is not able to connect to a configured anchore instance. Without this change the former command works as expected, but the second complains that it is unable to connect to anchore, even though the intent is just to display locally-stored help text. The reason for this is that it evaluates each part of the command in order, before moving to the next. So foranchore-cli image list -h, the cli tries to run the auth code inimageto make sure the cli can access the configured anchore instance.This change modifies the flow of execution so that (in this example)
imagereturns a callback to evaluate the auth of the user, to be executed by 'list'. This means thatanchore-cli image listwill still execute as expected, andanchore-cli image list -hwill skip the auth step because the-hflag preempts the normal execution of the code associated withlistand jsut return the help text.This is a WIP and still needs more testing before it can be merged.