mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-28 23:51:23 -07:00
Save the command line arguments into a global context
* Once cli args are parsed, they're constant. So, save the parsed args into the global context for everyone else to use them from now on. * Port cli scripts to use the CLIARGS in the context * Refactor call to parse cli args into the run() method * Fix unittests for changes to the internals of CLI arg parsing * Port callback plugins to use context.CLIARGS * Got rid of the private self._options attribute * Use context.CLIARGS in the individual callback plugins instead. * Also output positional arguments in default and unixy plugins * Code has been simplified since we're now dealing with a dict rather than Optparse.Value
This commit is contained in:
parent
c18da65089
commit
afdbb0d9d5
36 changed files with 1033 additions and 868 deletions
|
@ -25,6 +25,7 @@ __metaclass__ = type
|
|||
|
||||
import os
|
||||
|
||||
from ansible import context
|
||||
from ansible.errors import AnsibleError
|
||||
from ansible.module_utils.six import string_types
|
||||
|
||||
|
@ -35,19 +36,18 @@ from ansible.module_utils.six import string_types
|
|||
class Galaxy(object):
|
||||
''' Keeps global galaxy info '''
|
||||
|
||||
def __init__(self, options):
|
||||
def __init__(self):
|
||||
|
||||
self.options = options
|
||||
# self.options.roles_path needs to be a list and will be by default
|
||||
roles_path = getattr(self.options, 'roles_path', [])
|
||||
# cli option handling is responsible for making roles_path a list
|
||||
# roles_path needs to be a list and will be by default
|
||||
roles_path = context.CLIARGS.get('roles_path', tuple())
|
||||
# cli option handling is responsible for splitting roles_path
|
||||
self.roles_paths = roles_path
|
||||
|
||||
self.roles = {}
|
||||
|
||||
# load data path for resource usage
|
||||
this_dir, this_filename = os.path.split(__file__)
|
||||
type_path = getattr(self.options, 'role_type', "default")
|
||||
type_path = context.CLIARGS.get('role_type', "default")
|
||||
self.DATA_PATH = os.path.join(this_dir, 'data', type_path)
|
||||
|
||||
@property
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue