Skip to content

Commit fc55c21

Browse files
committed
Fix CLI embedding
1 parent 7044bd4 commit fc55c21

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

keystore/cli/cli.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const (
2525

2626
func NewRootCmd() *cobra.Command {
2727
cmd := &cobra.Command{
28-
Use: "./keystore <command>",
28+
Use: "keystore",
2929
Long: `
3030
CLI for managing keystore keys. Must specify KEYSTORE_FILE_PATH or KEYSTORE_DB_URL
3131
and KEYSTORE_PASSWORD in order to load the keystore.
@@ -336,16 +336,18 @@ func NewDecryptCmd() *cobra.Command {
336336
}
337337

338338
func loadKeystore(ctx context.Context, cmd *cobra.Command) (ks.Keystore, error) {
339-
root := cmd.Root()
340-
filePath, err := root.Flags().GetString("keystore-file-path")
339+
// Use parent command which has the persistent flags.
340+
// This works whether keystore CLI is standalone or embedded as a subcommand.
341+
parent := cmd.Parent()
342+
filePath, err := parent.Flags().GetString("keystore-file-path")
341343
if err != nil {
342344
return nil, err
343345
}
344-
dbURL, err := root.Flags().GetString("keystore-db-url")
346+
dbURL, err := parent.Flags().GetString("keystore-db-url")
345347
if err != nil {
346348
return nil, err
347349
}
348-
password, err := cmd.Flags().GetString("keystore-password")
350+
password, err := parent.Flags().GetString("keystore-password")
349351
if err != nil {
350352
return nil, err
351353
}

0 commit comments

Comments
 (0)