mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 17:50:20 +00:00
name the arguments and allow description to be set on command line
This commit is contained in:
parent
836002d3d0
commit
df2d4f7798
3 changed files with 21 additions and 6 deletions
|
@ -498,11 +498,15 @@ def salt_spm():
|
|||
spm.run()
|
||||
|
||||
|
||||
def salt_extend(extension, name, salt_dir, merge):
|
||||
def salt_extend(extension, name, description, salt_dir, merge):
|
||||
'''
|
||||
Quickstart for developing on the saltstack installation
|
||||
|
||||
.. versionadded:: Carbon
|
||||
'''
|
||||
import salt.utils.extend
|
||||
salt.utils.extend.run(extension, name, salt_dir, merge)
|
||||
salt.utils.extend.run(extension=extension,
|
||||
name=name,
|
||||
description=description,
|
||||
salt_dir=salt_dir,
|
||||
merge=merge)
|
||||
|
|
|
@ -17,13 +17,15 @@ try:
|
|||
except ImportError as ie:
|
||||
HAS_COOKIECUTTER = False
|
||||
|
||||
# Extend this list to add new template types, the first element is the name of the directory
|
||||
# inside templates/
|
||||
MODULE_OPTIONS = [
|
||||
('module', 'Execution module'),
|
||||
('state', 'State module'),
|
||||
]
|
||||
|
||||
|
||||
def run(extension=None, name=None, salt_dir='.', merge=False, temp_dir=None):
|
||||
def run(extension=None, name=None, description=None, salt_dir=None, merge=False, temp_dir=None):
|
||||
assert HAS_COOKIECUTTER, "Cookiecutter is not installed, please install using pip or " \
|
||||
"from https://github.com/audreyr/cookiecutter"
|
||||
|
||||
|
@ -39,7 +41,11 @@ def run(extension=None, name=None, salt_dir='.', merge=False, temp_dir=None):
|
|||
print('Enter the short name for the module (e.g. mymodule)')
|
||||
name = prompt.read_user_variable('Module name', '')
|
||||
|
||||
short_description = prompt.read_user_variable('Short description of the module', '')
|
||||
if salt_dir is None:
|
||||
salt_dir = '.'
|
||||
|
||||
if description is None:
|
||||
description = prompt.read_user_variable('Short description of the module', '')
|
||||
|
||||
template_dir = 'templates/{0}'.format(extension_type)
|
||||
project_name = name
|
||||
|
@ -49,7 +55,7 @@ def run(extension=None, name=None, salt_dir='.', merge=False, temp_dir=None):
|
|||
"email": "",
|
||||
"project_name": project_name,
|
||||
"repo_name": project_name,
|
||||
"project_short_description": short_description,
|
||||
"project_short_description": description,
|
||||
"release_date": date.today().strftime('%Y-%m-%d'),
|
||||
"year": date.today().strftime('%Y'),
|
||||
}
|
||||
|
|
|
@ -14,12 +14,16 @@ if __name__ == '__main__':
|
|||
help="Extension type, e.g. 'module', 'state'.")
|
||||
parser.add_argument(
|
||||
"--salt-directory",
|
||||
"-d",
|
||||
"-o",
|
||||
help="Directory where your salt installation is kept (defaults to .).")
|
||||
parser.add_argument(
|
||||
"--name",
|
||||
"-n",
|
||||
help="Module name.")
|
||||
parser.add_argument(
|
||||
"--description",
|
||||
"-d",
|
||||
help="Short description of what the module does.")
|
||||
parser.add_argument(
|
||||
"--no-merge",
|
||||
help="Don't merge the module into the salt directory, keep in a temp location",
|
||||
|
@ -28,5 +32,6 @@ if __name__ == '__main__':
|
|||
|
||||
salt_extend(extension=args.extension,
|
||||
name=args.name,
|
||||
description=args.description,
|
||||
salt_dir=args.salt_directory,
|
||||
merge=not args.no_merge)
|
||||
|
|
Loading…
Add table
Reference in a new issue