mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-27 21:01:27 -07:00
Migrate command line parsing to argparse (#50610)
* Start of migration to argparse * various fixes and improvements * Linting fixes * Test fixes * Fix vault_password_files * Add PrependAction for argparse * A bunch of additional tweak/fixes * Fix ansible-config tests * Fix man page generation * linting fix * More adhoc pattern fixes * Add changelog fragment * Add support for argcomplete * Enable argcomplete global completion * Rename PrependAction to PrependListAction to better describe what it does * Add documentation for installing and configuring argcomplete * Address rebase issues * Fix display encoding for vault * Fix line length * Address rebase issues * Handle rebase issues * Use mutually exclusive group instead of handling manually * Fix rebase issues * Address rebase issue * Update version added for argcomplete support * -e must be given a value * ci_complete
This commit is contained in:
parent
7ee6c136fd
commit
db6cc60352
28 changed files with 930 additions and 914 deletions
|
@ -10,8 +10,8 @@ import stat
|
|||
|
||||
from ansible import context
|
||||
from ansible.cli import CLI
|
||||
from ansible.cli.arguments import optparse_helpers as opt_help
|
||||
from ansible.errors import AnsibleError, AnsibleOptionsError
|
||||
from ansible.cli.arguments import option_helpers as opt_help
|
||||
from ansible.errors import AnsibleError
|
||||
from ansible.executor.playbook_executor import PlaybookExecutor
|
||||
from ansible.module_utils._text import to_bytes
|
||||
from ansible.playbook.block import Block
|
||||
|
@ -46,25 +46,23 @@ class PlaybookCLI(CLI):
|
|||
opt_help.add_module_options(self.parser)
|
||||
|
||||
# ansible playbook specific opts
|
||||
self.parser.add_option('--list-tasks', dest='listtasks', action='store_true',
|
||||
help="list all tasks that would be executed")
|
||||
self.parser.add_option('--list-tags', dest='listtags', action='store_true',
|
||||
help="list all available tags")
|
||||
self.parser.add_option('--step', dest='step', action='store_true',
|
||||
help="one-step-at-a-time: confirm each task before running")
|
||||
self.parser.add_option('--start-at-task', dest='start_at_task',
|
||||
help="start the playbook at the task matching this name")
|
||||
self.parser.add_argument('--list-tasks', dest='listtasks', action='store_true',
|
||||
help="list all tasks that would be executed")
|
||||
self.parser.add_argument('--list-tags', dest='listtags', action='store_true',
|
||||
help="list all available tags")
|
||||
self.parser.add_argument('--step', dest='step', action='store_true',
|
||||
help="one-step-at-a-time: confirm each task before running")
|
||||
self.parser.add_argument('--start-at-task', dest='start_at_task',
|
||||
help="start the playbook at the task matching this name")
|
||||
self.parser.add_argument('args', help='Playbook(s)', metavar='playbook', nargs='+')
|
||||
|
||||
def post_process_args(self, options, args):
|
||||
options, args = super(PlaybookCLI, self).post_process_args(options, args)
|
||||
|
||||
if len(args) == 0:
|
||||
raise AnsibleOptionsError("You must specify a playbook file to run")
|
||||
def post_process_args(self, options):
|
||||
options = super(PlaybookCLI, self).post_process_args(options)
|
||||
|
||||
display.verbosity = options.verbosity
|
||||
self.validate_conflicts(options, runas_opts=True, vault_opts=True, fork_opts=True)
|
||||
self.validate_conflicts(options, runas_opts=True, fork_opts=True)
|
||||
|
||||
return options, args
|
||||
return options
|
||||
|
||||
def run(self):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue