summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorBrian Coca <brian.coca+git@gmail.com>2015-11-02 14:34:08 -0500
committerBrian Coca <brian.coca+git@gmail.com>2015-11-02 14:35:06 -0500
commitd0a22a7b45028b9376c60c5119c5591be0d97697 (patch)
tree59adccb68e05cd00f8e795d1c4b0069424a2a429 /bin
parent99561e88d40645ab4fa9bcb4d7d454b2088ad241 (diff)
downloadansible-d0a22a7b45028b9376c60c5119c5591be0d97697.tar.gz
made cli code more flexible to add new command line programs w/o need for updating bin/ansible
Diffstat (limited to 'bin')
-rwxr-xr-xbin/ansible25
1 files changed, 11 insertions, 14 deletions
diff --git a/bin/ansible b/bin/ansible
index 085a8e0f4e..7420c2cc30 100755
--- a/bin/ansible
+++ b/bin/ansible
@@ -61,22 +61,19 @@ if __name__ == '__main__':
try:
display = Display()
- if me == 'ansible-playbook':
- from ansible.cli.playbook import PlaybookCLI as mycli
- elif me == 'ansible':
- from ansible.cli.adhoc import AdHocCLI as mycli
- elif me == 'ansible-pull':
- from ansible.cli.pull import PullCLI as mycli
- elif me == 'ansible-doc':
- from ansible.cli.doc import DocCLI as mycli
- elif me == 'ansible-vault':
- from ansible.cli.vault import VaultCLI as mycli
- elif me == 'ansible-galaxy':
- from ansible.cli.galaxy import GalaxyCLI as mycli
-
+ sub = None
try:
+ if me.find('-') != -1:
+ target = me.split('-')
+ if len(target) > 1:
+ sub = target[1]
+ myclass = "%sCLI" % sub.capitalize()
+ mycli = getattr(__import__("ansible.cli.%s" % sub, fromlist=[myclass]), myclass)
+ elif me == 'ansible':
+ from ansible.cli.adhoc import AdHocCLI as mycli
+
cli = mycli(sys.argv, display=display)
- except NameError:
+ except (ImportError,NameError):
raise AnsibleError("Ansible sub-program not implemented: %s" % me)
cli.parse()