Don't insist on ansible-vault taking only one filename parameter

Apart from ansible-vault create, every vault subcommand is happy to deal
with multiple filenames, so we can check that there's at least one, and
make create check separately that there aren't any extra.
pull/12061/head
Abhijit Menon-Sen 9 years ago committed by Brian Coca
parent f1b8323b62
commit 3aedc0bca9

@ -64,8 +64,8 @@ class VaultCLI(CLI):
self.options, self.args = self.parser.parse_args() self.options, self.args = self.parser.parse_args()
self.display.verbosity = self.options.verbosity self.display.verbosity = self.options.verbosity
if len(self.args) == 0 or len(self.args) > 1: if len(self.args) == 0:
raise AnsibleOptionsError("Vault requires a single filename as a parameter") raise AnsibleOptionsError("Vault requires at least one filename as a parameter")
def run(self): def run(self):
@ -84,6 +84,9 @@ class VaultCLI(CLI):
def execute_create(self): def execute_create(self):
if len(self.args) > 1:
raise AnsibleOptionsError("ansible-vault create can take only one filename argument")
cipher = getattr(self.options, 'cipher', self.CIPHER) cipher = getattr(self.options, 'cipher', self.CIPHER)
this_editor = VaultEditor(cipher, self.vault_pass, self.args[0]) this_editor = VaultEditor(cipher, self.vault_pass, self.args[0])
this_editor.create_file() this_editor.create_file()

Loading…
Cancel
Save