Skip to content

Commit 0b3aac5

Browse files
authored
Merge pull request #72 from trickest/create-project-flag
Add flag for creating non-existing projects before execution
2 parents 1d495e1 + d104973 commit 0b3aac5

File tree

2 files changed

+28
-43
lines changed

2 files changed

+28
-43
lines changed

README.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ Current workflow categories are:
3737

3838
```
3939
# Download the binary
40-
wget https://github.com/trickest/trickest-cli/releases/download/v1.1.0/trickest-cli-1.1.0-macOS-arm64.zip
40+
wget https://github.com/trickest/trickest-cli/releases/download/v1.1.1/trickest-cli-1.1.1-macOS-arm64.zip
4141
4242
# Unzip
43-
unzip trickest-cli-1.1.0-macOS-arm64.zip
43+
unzip trickest-cli-1.1.1-macOS-arm64.zip
4444
4545
# Make binary executable
4646
chmod +x trickest-cli-macOS-arm64
@@ -55,10 +55,10 @@ trickest --help
5555
#### **Linux**
5656

5757
```
58-
wget https://github.com/trickest/trickest-cli/releases/download/v1.1.0/trickest-cli-1.1.0-linux-amd64.zip
58+
wget https://github.com/trickest/trickest-cli/releases/download/v1.1.1/trickest-cli-1.1.1-linux-amd64.zip
5959
6060
# Unzip
61-
unzip trickest-cli-1.1.0-linux-amd64.zip
61+
unzip trickest-cli-1.1.1-linux-amd64.zip
6262
6363
# Make binary executable
6464
chmod +x trickest-cli-linux-amd64
@@ -148,18 +148,19 @@ Use the **execute** command to execute a particular workflow or tool.
148148
trickest execute --workflow <workflow_or_tool_name> --space <space_name> --config <config_file_path> --set-name "New Name" [--watch]
149149
```
150150

151-
| Flag | Type | Default | Description |
152-
| ------------- | ------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
153-
| --config | file | / | YAML file for run configuration |
154-
| --workflow | string | / | Workflow from the Store to be executed |
155-
| --max | boolean | / | Use maximum number of machines for workflow execution |
156-
| --output | string | / | A comma-separated list of nodes whose outputs should be downloaded when the execution is finished |
157-
| --output-all | boolean | / | Download all outputs when the execution is finished |
158-
| --output-dir | string | . | Path to the directory which should be used to store outputs |
159-
| --show-params | boolean | / | Show parameters in the workflow tree |
160-
| --watch | boolean | / | Option to track execution status in case workflow is in running state |
161-
| --set-name | string | / | Sets the new workflow name and will copy the workflow to space and project supplied |
162-
| --ci | boolean | false | Enable CI mode (in-progreess executions will be stopped when the CLI is forcefully stopped - if not set, you will be asked for confirmation) |
151+
| Flag | Type | Default | Description |
152+
|------------------|---------|---------|---------------------------------------------------------------------------------------------------------------------------------------------|
153+
| --config | file | / | YAML file for run configuration |
154+
| --workflow | string | / | Workflow from the Store to be executed |
155+
| --max | boolean | / | Use maximum number of machines for workflow execution |
156+
| --output | string | / | A comma-separated list of nodes whose outputs should be downloaded when the execution is finished |
157+
| --output-all | boolean | / | Download all outputs when the execution is finished |
158+
| --output-dir | string | . | Path to the directory which should be used to store outputs |
159+
| --show-params | boolean | / | Show parameters in the workflow tree |
160+
| --watch | boolean | / | Option to track execution status in case workflow is in running state |
161+
| --set-name | string | / | Sets the new workflow name and will copy the workflow to space and project supplied |
162+
| --ci | boolean | false | Enable CI mode (in-progress executions will be stopped when the CLI is forcefully stopped - if not set, you will be asked for confirmation) |
163+
| --create-project | boolean | false | If the project doesn't exist, create one using the project flag as its name (or workflow/tool name if project flag is not set) |
163164

164165
#### Provide parameters using **config.yaml** file
165166

cmd/execute/execute.go

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ var (
3737
outputsDirectory string
3838
outputNodesFlag string
3939
ci bool
40+
createProject bool
4041
)
4142

4243
// ExecuteCmd represents the execute command
@@ -111,6 +112,7 @@ func init() {
111112
ExecuteCmd.Flags().StringVar(&outputNodesFlag, "output", "", "A comma separated list of nodes which outputs should be downloaded when the execution is finished")
112113
ExecuteCmd.Flags().StringVar(&outputsDirectory, "output-dir", "", "Path to directory which should be used to store outputs")
113114
ExecuteCmd.Flags().BoolVar(&ci, "ci", false, "Run in CI mode (in-progreess executions will be stopped when the CLI is forcefully stopped - if not set, you will be asked for confirmation)")
115+
ExecuteCmd.Flags().BoolVar(&createProject, "create-project", false, "If the project doesn't exist, create it using the project flag as its name (or workflow name if not set)")
114116
}
115117

116118
func readWorkflowYAMLandCreateVersion(fileName string, workflowName string, objectPath string) *types.WorkflowVersionDetailed {
@@ -912,24 +914,13 @@ func prepareForExec(objectPath string) *types.WorkflowVersionDetailed {
912914
// Executing from store
913915
for _, wf := range storeWorkflows {
914916
if strings.ToLower(wf.Name) == strings.ToLower(wfName) {
915-
if project == nil {
917+
if project == nil && createProject {
916918
projectName := util.ProjectName
917919
if projectName == "" {
918920
projectName = wfName
919921
}
920-
fmt.Println("Would you like to create a project named " + projectName +
921-
" and save the new workflow in there? (Y/N)")
922-
var answer string
923-
for {
924-
_, _ = fmt.Scan(&answer)
925-
if strings.ToLower(answer) == "y" || strings.ToLower(answer) == "yes" {
926-
project = create.CreateProjectIfNotExists(space, projectName)
927-
projectCreated = true
928-
break
929-
} else if strings.ToLower(answer) == "n" || strings.ToLower(answer) == "no" {
930-
break
931-
}
932-
}
922+
project = create.CreateProjectIfNotExists(space, projectName)
923+
projectCreated = true
933924
}
934925

935926
if newWorkflowName == "" {
@@ -1014,20 +1005,13 @@ func prepareForExec(objectPath string) *types.WorkflowVersionDetailed {
10141005
}
10151006
_, _, primitiveNodes = readConfig(configFile, nil, &tools[0])
10161007

1017-
if project == nil {
1018-
fmt.Println("Would you like to create a project named " + wfName +
1019-
" and save the new workflow in there? (Y/N)")
1020-
var answer string
1021-
for {
1022-
_, _ = fmt.Scan(&answer)
1023-
if strings.ToLower(answer) == "y" || strings.ToLower(answer) == "yes" {
1024-
project = create.CreateProjectIfNotExists(space, tools[0].Name)
1025-
projectCreated = true
1026-
break
1027-
} else if strings.ToLower(answer) == "n" || strings.ToLower(answer) == "no" {
1028-
break
1029-
}
1008+
if project == nil && createProject {
1009+
projectName := util.ProjectName
1010+
if projectName == "" {
1011+
projectName = wfName
10301012
}
1013+
project = create.CreateProjectIfNotExists(space, tools[0].Name)
1014+
projectCreated = true
10311015
}
10321016
if newWorkflowName == "" {
10331017
newWorkflowName = wfName

0 commit comments

Comments
 (0)