Skip to content

Commit 3ab05a7

Browse files
committed
_cli: hackety hack
Signed-off-by: William Woodruff <[email protected]>
1 parent 769bafd commit 3ab05a7

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

sigstore/_cli.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,17 @@ def _set_default_verify_subparser(parser: argparse.ArgumentParser, name: str) ->
100100
if sp_name in sys.argv[1:]:
101101
subparser_found = True
102102
if not subparser_found:
103-
# If `sigstore verify identity` wasn't passed explicitly, we need
104-
# to insert the `identity` subcommand into the correct position
105-
# within `sys.argv`. To do that, we get the index of the `verify`
106-
# subcommand, and insert it directly after it.
107-
verify_idx = sys.argv.index("verify")
108-
sys.argv.insert(verify_idx + 1, name)
103+
try:
104+
# If `sigstore verify identity` wasn't passed explicitly, we need
105+
# to insert the `identity` subcommand into the correct position
106+
# within `sys.argv`. To do that, we get the index of the `verify`
107+
# subcommand, and insert it directly after it.
108+
verify_idx = sys.argv.index("verify")
109+
sys.argv.insert(verify_idx + 1, name)
110+
except ValueError:
111+
# This happens when we invoke `sigstore sign`, since there's no
112+
# `verify` subcommand to insert under. We do nothing in this case.
113+
pass
109114

110115

111116
def _add_shared_instance_options(group: argparse._ArgumentGroup) -> None:

0 commit comments

Comments
 (0)