diff --git a/CHANGELOG.md b/CHANGELOG.md index 12b177ccf76..0460a52f43e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ * Added backwards compatibility break error message. * Added schema for incident types. * Added **additionalinfo** field to as an available field for integration configuration. +* Added pack parameter for **init**. +* Fixed an issue where error would appear if name parameter is not set in **init**. ### 0.3.2 * Fixed the handling of classifier files in **validate**. diff --git a/README.md b/README.md index 13c2239afca..d5adb3f227f 100644 --- a/README.md +++ b/README.md @@ -147,7 +147,7 @@ Run Secrets validator to catch sensitive data before exposing your code to publi This will help the command to determine which files it should check in its run. Before you commit the files it should not be used. Mostly for build validations. (default: False) - + * **-wl WHITELIST, --whitelist WHITELIST* Full path to whitelist file, file name should be "secrets_white_list.json" (default: ./Tests/secrets_white_list.json) @@ -296,8 +296,9 @@ Create a pack, integration or script template. If `--integration` and `--script` * **-n, --name** The name given to the files and directories of new pack/integration/script being created * **--id** The id used for the yml file of the integration/script * **-o, --outdir** The directory to which the created object will be saved -* **--integration** Create an integration -* **--script** Create a script +* **--integration** Create an integration. +* **--script** Create a script. +* **--pack** Create a pack. **Example**: `demisto-sdk init --integration -n MyNewIntegration -o path/to/my/dir` diff --git a/demisto_sdk/common/templates/HelloWorld/HelloWorld.py b/demisto_sdk/common/templates/HelloWorld/HelloWorld.py index 3026adeeee9..bd6695c49a5 100644 --- a/demisto_sdk/common/templates/HelloWorld/HelloWorld.py +++ b/demisto_sdk/common/templates/HelloWorld/HelloWorld.py @@ -1,6 +1,5 @@ import demistomock as demisto from CommonServerPython import * -from CommonServerPython import BaseClient from CommonServerUserPython import * # IMPORTS diff --git a/demisto_sdk/dev_tools/initiator.py b/demisto_sdk/dev_tools/initiator.py index 60b91a5cea3..2268230376b 100644 --- a/demisto_sdk/dev_tools/initiator.py +++ b/demisto_sdk/dev_tools/initiator.py @@ -23,17 +23,25 @@ class Initiator: full_output_path (str): The full path to the newly created pack/integration/script """ - def __init__(self, output_dir: str, name: str = '', id: str = '', integration: bool = False, script: bool = False): + def __init__(self, output_dir: str, name: str = '', id: str = '', integration: bool = False, script: bool = False, + pack: bool = False): self.output_dir = output_dir if output_dir else '' self.id = id self.is_integration = integration self.is_script = script + self.is_pack = pack + + # if no flag given automatically create a pack. + if not integration and not script and not pack: + self.is_pack = True self.full_output_path = '' - while ' ' in name: - name = str(input("The directory and file name cannot have spaces in it, Enter a different name: ")) + if len(name) != 0: + while ' ' in name: + name = str(input("The directory and file name cannot have spaces in it, Enter a different name: ")) + self.dir_name = name self.is_pack_creation = not all([self.is_script, self.is_integration]) @@ -57,7 +65,7 @@ def init(self): self.get_object_id(created_object="script") return self.script_init() - else: + elif self.is_pack: self.get_created_dir_name(created_object="pack") return self.pack_init() diff --git a/demisto_sdk/main.py b/demisto_sdk/main.py index 07d9512bc04..2f3b68b481b 100644 --- a/demisto_sdk/main.py +++ b/demisto_sdk/main.py @@ -462,6 +462,7 @@ def generate_test_playbook(**kwargs): '--integration', is_flag=True, help="Create an Integration based on HelloWorld example") @click.option( '--script', is_flag=True, help="Create a script based on HelloWorldScript example") +@click.option("--pack", is_flag=True, help="Create pack and its sub directories") def init(**kwargs): initiator = Initiator(**kwargs) initiator.init() diff --git a/docs/init_command.md b/docs/init_command.md index 6f4ccd16d4a..a812a8513b9 100644 --- a/docs/init_command.md +++ b/docs/init_command.md @@ -10,8 +10,10 @@ This command is used to ease the initial creation of a pack, integration or a sc * **-o, --outdir** The directory to which the created object will be saved. * **--integration** Create an integration * **--script** Create a script +* **--pack** Create a pack **Notes** +* If `integration` or `script` not set - the command will automatically create a pack, even if `pack` was not set. * If a `name` will not be given, a prompt will show asking for an input - A pack, integration or script can not be created without a given `name`. * The `name` parameter *can not* have spaces (' ') in it. @@ -25,7 +27,7 @@ An integration will be created in the "Integrations" directory and a script will The pack/integration/script will be created in your current working directory. * The templates are based on "Integrations/HelloWorld" and "Scripts/HelloWorldScript" found in content repo. -**Examples** +**Examples** *Note: the bellow example explanations are given as though this command is activated from content repo directory.* `demisto-sdk init` @@ -37,3 +39,6 @@ This will create a new integration template named MyNewIntegration within "path/ `demisto-sdk init --script --id "My Script ID"` This will prompt a message asking for a name for the script's directory and file name, once given a script will be created under "Scripts" directory and the yml file will have the id "My Script ID". + +`demisto-sdk init --pack -n My_Pack` +This will create a new pack named "My_Pack" under the "Packs" directory in content repo.