Skip to content

secrets env needs -- to be passed twice to parse the command #325

@aryanjassal

Description

@aryanjassal

Specification

When running the secrets env command in the tests, we only need to pass -- once, and that will delimit the commands and the vault names.

However, this is not the case when running the program on the CLI, as we need to write -- twice to get it to work. For example, the following will work in the tests but not in CLI.

# In jest
[aryanj@matrix-34xx:~]$ polykey secrets env vault -- echo 'hi'
TESTING='top secret'
hi
 
# In shell
[aryanj@matrix-34xx:~]$ polykey secrets env vault -- echo 'hi'
ErrorPolykeyRemote: Remote error from RPC call
  ...
  cause: ErrorVaultsVaultUndefined: Vault does not exist
 
[aryanj@matrix-34xx:~]$ polykey secrets env vault -- -- echo 'hi'
TESTING='top secret'
hi

It is difficult to see which vault was the offender for commands containing multiple vaults, like secrets commands. For those commands at least, the ErrorVaultsVaultUndefined should also return the name of the offending vault. For example, a command like this can be difficult to find the invalid vault.

[aryanj@matrix-34xx:~]$ polykey secrets cat test.vault:file1 anothr.vault:file2
ErrorPolykeyRemote: Remote error from RPC call
  ...
  cause: ErrorVaultsVaultUndefined: Vault does not exist

Without reading the command properly, the user won't know that the offending vault was a typo in another.

Additional context

  • Needing program.enablePositionalArguments enabled to use command.passThroughOptions, but enabling positional arguments breaks the commands: Polykey-CLI#325 and Polykey-CLI#329 (comment)
  • Upstream discussion on a solution without needing to enable positional arguments: commander.js#2281

Tasks

  1. Allow -- once in the CLI to run commands as opposed to twice
  2. Provide feedback by listing which vault was incorrect

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions