ansible-galaxy - more fixes for verbosity without sub type (#60604)

* ansible-galaxy - more fixes for verbosity without sub type

* remove testing line
This commit is contained in:
Jordan Borean 2019-08-15 11:53:40 +10:00 committed by GitHub
parent 25b20adb94
commit 4ebac7d5b7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View file

@ -44,7 +44,9 @@ class GalaxyCLI(CLI):
# Inject role into sys.argv[1] as a backwards compatibility step # Inject role into sys.argv[1] as a backwards compatibility step
if len(args) > 1 and args[1] not in ['-h', '--help'] and 'role' not in args and 'collection' not in args: if len(args) > 1 and args[1] not in ['-h', '--help'] and 'role' not in args and 'collection' not in args:
# TODO: Should we add a warning here and eventually deprecate the implicit role subcommand choice # TODO: Should we add a warning here and eventually deprecate the implicit role subcommand choice
args.insert(1, 'role') # Remove this in Ansible 2.13 when we also remove -v as an option on the root parser for ansible-galaxy.
idx = 2 if args[1].startswith('-v') else 1
args.insert(idx, 'role')
self.api = None self.api = None
self.galaxy = None self.galaxy = None

View file

@ -469,6 +469,8 @@ class TestGalaxyInitSkeleton(unittest.TestCase, ValidRoleTests):
# deprecated and tests should be removed when the code that handles it is removed # deprecated and tests should be removed when the code that handles it is removed
(['ansible-galaxy', '-vv', 'collection', 'init', 'abc.def', '-v'], 1), (['ansible-galaxy', '-vv', 'collection', 'init', 'abc.def', '-v'], 1),
(['ansible-galaxy', '-vv', 'collection', 'init', 'abc.def', '-vvvv'], 4), (['ansible-galaxy', '-vv', 'collection', 'init', 'abc.def', '-vvvv'], 4),
(['ansible-galaxy', '-vvv', 'init', 'name'], 3),
(['ansible-galaxy', '-vvvvv', 'init', '-v', 'name'], 1),
]) ])
def test_verbosity_arguments(cli_args, expected, monkeypatch): def test_verbosity_arguments(cli_args, expected, monkeypatch):
# Mock out the functions so we don't actually execute anything # Mock out the functions so we don't actually execute anything