Skip to content
This repository was archived by the owner on Jul 10, 2024. It is now read-only.

Conversation

@dspalmer99
Copy link
Contributor

@dspalmer99 dspalmer99 commented Dec 16, 2020

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 -h and anchore-cli image list -h. These commands should display the help text for image and list (the latter being a subcommand under the image group), 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 for anchore-cli image list -h, the cli tries to run the auth code in image to make sure the cli can access the configured anchore instance.

This change modifies the flow of execution so that (in this example) image returns a callback to evaluate the auth of the user, to be executed by 'list'. This means that anchore-cli image list will still execute as expected, and anchore-cli image list -h will skip the auth step because the -h flag preempts the normal execution of the code associated with list and jsut return the help text.

This is a WIP and still needs more testing before it can be merged.

@dspalmer99 dspalmer99 changed the title Issue 128 Consistent help behavior Dec 16, 2020
@dspalmer99 dspalmer99 requested a review from zhill December 22, 2020 13:14
…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>
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement] Remove endpoint check in subcmd path to allow --help and exploration of cli without a system Inconsistency with help behavior

1 participant