1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

ansible-pull: allow specifying --diff from check_opts cli flag group (#37645)

This commit is contained in:
Daniel Nägele 2018-08-28 21:15:14 +02:00 committed by Brian Coca
parent 966c87e111
commit edaa0b5245

View file

@ -29,6 +29,7 @@ import sys
import time
from ansible.cli import CLI
from ansible import constants as C
from ansible.errors import AnsibleOptionsError
from ansible.module_utils._text import to_native, to_text
from ansible.plugins.loader import module_loader
@ -91,6 +92,7 @@ class PullCLI(CLI):
vault_opts=True,
runtask_opts=True,
subset_opts=True,
check_opts=False, # prevents conflict of --checkout/-C and --check/-C
inventory_opts=True,
module_opts=True,
runas_prompt_opts=True,
@ -123,8 +125,12 @@ class PullCLI(CLI):
help='modified files in the working repository will be discarded')
self.parser.add_option('--track-subs', dest='tracksubs', default=False, action='store_true',
help='submodules will track the latest changes. This is equivalent to specifying the --remote flag to git submodule update')
# add a subset of the check_opts flag group manually, as the full set's
# shortcodes conflict with above --checkout/-C
self.parser.add_option("--check", default=False, dest='check', action='store_true',
help="don't make any changes; instead, try to predict some of the changes that may occur")
self.parser.add_option("--diff", default=C.DIFF_ALWAYS, dest='diff', action='store_true',
help="when changing (small) files and templates, show the differences in those files; works great with --check")
super(PullCLI, self).parse()
@ -276,6 +282,8 @@ class PullCLI(CLI):
cmd += ' -l "%s"' % limit_opts
if self.options.check:
cmd += ' -C'
if self.options.diff:
cmd += ' -D'
os.chdir(self.options.dest)