Skip to content

Commit

Permalink
Merge pull request #137 from demisto/init_fix
Browse files Browse the repository at this point in the history
init fix and adding pack param.
  • Loading branch information
ronykoz authored Jan 8, 2020
2 parents d6a3c42 + f1bfea5 commit dbda508
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
### 0.3.3
* Added backwards compatibility break error message.
* 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**.
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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`
Expand Down
1 change: 0 additions & 1 deletion demisto_sdk/common/templates/HelloWorld/HelloWorld.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import demistomock as demisto
from CommonServerPython import *
from CommonServerPython import BaseClient
from CommonServerUserPython import *
# IMPORTS

Expand Down
16 changes: 12 additions & 4 deletions demisto_sdk/dev_tools/initiator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])

Expand All @@ -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()

Expand Down
1 change: 1 addition & 0 deletions demisto_sdk/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
7 changes: 6 additions & 1 deletion docs/init_command.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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`
Expand All @@ -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.

0 comments on commit dbda508

Please sign in to comment.