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.
This commit is contained in:
Abhijit Menon-Sen 2015-08-22 19:47:15 +05:30 committed by Brian Coca
parent f1b8323b62
commit 3aedc0bca9

View file

@ -64,8 +64,8 @@ class VaultCLI(CLI):
self.options, self.args = self.parser.parse_args()
self.display.verbosity = self.options.verbosity
if len(self.args) == 0 or len(self.args) > 1:
raise AnsibleOptionsError("Vault requires a single filename as a parameter")
if len(self.args) == 0:
raise AnsibleOptionsError("Vault requires at least one filename as a parameter")
def run(self):
@ -84,6 +84,9 @@ class VaultCLI(CLI):
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)
this_editor = VaultEditor(cipher, self.vault_pass, self.args[0])
this_editor.create_file()