mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Added pydoc for functions in Cli()
This commit is contained in:
parent
e9a24cdad4
commit
bf967adf83
1 changed files with 10 additions and 0 deletions
10
bin/ansible
10
bin/ansible
|
@ -17,6 +17,8 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
########################################################
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import json
|
import json
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -32,7 +34,10 @@ import ansible.constants as C
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
from ansible.utils import *
|
from ansible.utils import *
|
||||||
|
|
||||||
|
########################################################
|
||||||
|
|
||||||
class Cli(object):
|
class Cli(object):
|
||||||
|
''' code behind bin/ansible '''
|
||||||
|
|
||||||
# ----------------------------------------------
|
# ----------------------------------------------
|
||||||
|
|
||||||
|
@ -42,6 +47,7 @@ class Cli(object):
|
||||||
# ----------------------------------------------
|
# ----------------------------------------------
|
||||||
|
|
||||||
def parse(self):
|
def parse(self):
|
||||||
|
''' create an options parser for bin/ansible '''
|
||||||
|
|
||||||
parser = OptionParser(usage = 'ansible <host-pattern> [options]')
|
parser = OptionParser(usage = 'ansible <host-pattern> [options]')
|
||||||
parser.add_option("-a", "--args", dest="module_args",
|
parser.add_option("-a", "--args", dest="module_args",
|
||||||
|
@ -74,6 +80,7 @@ class Cli(object):
|
||||||
# ----------------------------------------------
|
# ----------------------------------------------
|
||||||
|
|
||||||
def run(self, options, args):
|
def run(self, options, args):
|
||||||
|
''' use Runner lib to do SSH things '''
|
||||||
|
|
||||||
pattern = args[0]
|
pattern = args[0]
|
||||||
sshpass = None
|
sshpass = None
|
||||||
|
@ -96,6 +103,7 @@ class Cli(object):
|
||||||
# ----------------------------------------------
|
# ----------------------------------------------
|
||||||
|
|
||||||
def output(self, results, options, args):
|
def output(self, results, options, args):
|
||||||
|
''' summarize results from Runner '''
|
||||||
|
|
||||||
if results is None:
|
if results is None:
|
||||||
exit("No hosts matched")
|
exit("No hosts matched")
|
||||||
|
@ -119,6 +127,8 @@ class Cli(object):
|
||||||
|
|
||||||
print buf
|
print buf
|
||||||
|
|
||||||
|
########################################################
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
cli = Cli()
|
cli = Cli()
|
||||||
(options, args) = cli.parse()
|
(options, args) = cli.parse()
|
||||||
|
|
Loading…
Reference in a new issue