This commit is contained in:
@@ -27,7 +27,7 @@ type PostParamsBodySheetsItems struct {
|
|||||||
InputFile []apps.DirektivFile `json:"input-file"`
|
InputFile []apps.DirektivFile `json:"input-file"`
|
||||||
|
|
||||||
// Label for the worksheet created in the spreadsheet
|
// Label for the worksheet created in the spreadsheet
|
||||||
WorksheetName *string `json:"worksheet-name,omitempty"`
|
Name *string `json:"name,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate validates this post params body sheets items
|
// Validate validates this post params body sheets items
|
||||||
|
@@ -94,7 +94,7 @@ func init() {
|
|||||||
"$ref": "#/definitions/direktivFile"
|
"$ref": "#/definitions/direktivFile"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"worksheet-name": {
|
"name": {
|
||||||
"description": "Label for the worksheet created in the spreadsheet",
|
"description": "Label for the worksheet created in the spreadsheet",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"default": "Sheet1"
|
"default": "Sheet1"
|
||||||
@@ -141,7 +141,7 @@ func init() {
|
|||||||
"cmds": [
|
"cmds": [
|
||||||
{
|
{
|
||||||
"action": "foreach",
|
"action": "foreach",
|
||||||
"exec": "/bin/json2excel -inputJson {{- if eq (deref .Item.Infile) \"\" }} \"input.json\" {{- else }} {{ .Item.Infile }} {{- end }} -worksheetName \"{{ .Item.WorksheetName }}\" -outputFilename '{{ .OutFilename }}'",
|
"exec": "/bin/json2excel -inputJson {{- if eq (deref .Item.Infile) \"\" }} \"input.json\" {{- else }} {{ .Item.Infile }} {{- end }} -worksheetName \"{{ .Item.Name }}\" -outputFilename '{{ .OutFilename }}'",
|
||||||
"loop": ".Sheets",
|
"loop": ".Sheets",
|
||||||
"print": true,
|
"print": true,
|
||||||
"silent": false
|
"silent": false
|
||||||
@@ -160,11 +160,11 @@ func init() {
|
|||||||
},
|
},
|
||||||
"x-direktiv-examples": [
|
"x-direktiv-examples": [
|
||||||
{
|
{
|
||||||
"content": "- id: export-xlsx\n type: action\n action:\n function: export-xlsx\n input: \n out-filename: example.xlsx\n sheets:\n - sheet:\n worksheet-name: \"TestSpreadsheet\"\n input-file:\n - name: input.json\n data: |\n jq(.input)",
|
"content": "- id: export-xlsx\n type: action\n action:\n function: export-xlsx\n input: \n out-filename: example.xlsx\n sheets:\n - name: \"TestSpreadsheet\"\n input-file:\n - name: input.json\n data: |\n jq(.input)",
|
||||||
"title": "Basic"
|
"title": "Basic"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"content": "- id: export-xlsx\n type: action\n action:\n function: export-xlsx\n input: \n out-filename: example.xlsx \n sheets:\n - sheet:\n worksheet-name: \"TestSpreadsheet\"\n input-file:\n - name: input.json\n data: |\n jq(.array | {input: . } | tostring ) ",
|
"content": "- id: export-xlsx\n type: action\n action:\n function: export-xlsx\n input: \n out-filename: example.xlsx \n sheets:\n - name: \"TestSpreadsheet\"\n input-file:\n - name: input.json\n data: |\n jq(.array | {input: . } | tostring ) ",
|
||||||
"title": "Use jq to add a parent key 'input' containing array of objects"
|
"title": "Use jq to add a parent key 'input' containing array of objects"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -305,7 +305,7 @@ func init() {
|
|||||||
"cmds": [
|
"cmds": [
|
||||||
{
|
{
|
||||||
"action": "foreach",
|
"action": "foreach",
|
||||||
"exec": "/bin/json2excel -inputJson {{- if eq (deref .Item.Infile) \"\" }} \"input.json\" {{- else }} {{ .Item.Infile }} {{- end }} -worksheetName \"{{ .Item.WorksheetName }}\" -outputFilename '{{ .OutFilename }}'",
|
"exec": "/bin/json2excel -inputJson {{- if eq (deref .Item.Infile) \"\" }} \"input.json\" {{- else }} {{ .Item.Infile }} {{- end }} -worksheetName \"{{ .Item.Name }}\" -outputFilename '{{ .OutFilename }}'",
|
||||||
"loop": ".Sheets",
|
"loop": ".Sheets",
|
||||||
"print": true,
|
"print": true,
|
||||||
"silent": false
|
"silent": false
|
||||||
@@ -324,11 +324,11 @@ func init() {
|
|||||||
},
|
},
|
||||||
"x-direktiv-examples": [
|
"x-direktiv-examples": [
|
||||||
{
|
{
|
||||||
"content": "- id: export-xlsx\n type: action\n action:\n function: export-xlsx\n input: \n out-filename: example.xlsx\n sheets:\n - sheet:\n worksheet-name: \"TestSpreadsheet\"\n input-file:\n - name: input.json\n data: |\n jq(.input)",
|
"content": "- id: export-xlsx\n type: action\n action:\n function: export-xlsx\n input: \n out-filename: example.xlsx\n sheets:\n - name: \"TestSpreadsheet\"\n input-file:\n - name: input.json\n data: |\n jq(.input)",
|
||||||
"title": "Basic"
|
"title": "Basic"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"content": "- id: export-xlsx\n type: action\n action:\n function: export-xlsx\n input: \n out-filename: example.xlsx \n sheets:\n - sheet:\n worksheet-name: \"TestSpreadsheet\"\n input-file:\n - name: input.json\n data: |\n jq(.array | {input: . } | tostring ) ",
|
"content": "- id: export-xlsx\n type: action\n action:\n function: export-xlsx\n input: \n out-filename: example.xlsx \n sheets:\n - name: \"TestSpreadsheet\"\n input-file:\n - name: input.json\n data: |\n jq(.array | {input: . } | tostring ) ",
|
||||||
"title": "Use jq to add a parent key 'input' containing array of objects"
|
"title": "Use jq to add a parent key 'input' containing array of objects"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -431,7 +431,7 @@ func init() {
|
|||||||
"$ref": "#/definitions/direktivFile"
|
"$ref": "#/definitions/direktivFile"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"worksheet-name": {
|
"name": {
|
||||||
"description": "Label for the worksheet created in the spreadsheet",
|
"description": "Label for the worksheet created in the spreadsheet",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"default": "Sheet1"
|
"default": "Sheet1"
|
||||||
|
@@ -185,7 +185,7 @@ func runCommand0(ctx context.Context,
|
|||||||
params.DirektivDir,
|
params.DirektivDir,
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd, err := templateString(`/bin/json2excel -inputJson {{- if eq (deref .Item.Infile) "" }} "input.json" {{- else }} {{ .Item.Infile }} {{- end }} -worksheetName "{{ .Item.WorksheetName }}" -outputFilename '{{ .OutFilename }}'`, ls)
|
cmd, err := templateString(`/bin/json2excel -inputJson {{- if eq (deref .Item.Infile) "" }} "input.json" {{- else }} {{ .Item.Infile }} {{- end }} -worksheetName "{{ .Item.Name }}" -outputFilename '{{ .OutFilename }}'`, ls)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ir := make(map[string]interface{})
|
ir := make(map[string]interface{})
|
||||||
ir[successKey] = false
|
ir[successKey] = false
|
||||||
|
16
readme.md
16
readme.md
@@ -33,12 +33,11 @@ functions:
|
|||||||
input:
|
input:
|
||||||
out-filename: example.xlsx
|
out-filename: example.xlsx
|
||||||
sheets:
|
sheets:
|
||||||
- sheet:
|
- name: "TestSpreadsheet"
|
||||||
worksheet-name: "TestSpreadsheet"
|
input-file:
|
||||||
input-file:
|
- name: input.json
|
||||||
- name: input.json
|
data: |
|
||||||
data: |
|
jq(.input)
|
||||||
jq(.input)
|
|
||||||
```
|
```
|
||||||
#### Use jq to add a parent key 'input' containing array of objects
|
#### Use jq to add a parent key 'input' containing array of objects
|
||||||
```yaml
|
```yaml
|
||||||
@@ -49,8 +48,7 @@ functions:
|
|||||||
input:
|
input:
|
||||||
out-filename: example.xlsx
|
out-filename: example.xlsx
|
||||||
sheets:
|
sheets:
|
||||||
- sheet:
|
- name: "TestSpreadsheet"
|
||||||
worksheet-name: "TestSpreadsheet"
|
|
||||||
input-file:
|
input-file:
|
||||||
- name: input.json
|
- name: input.json
|
||||||
data: |
|
data: |
|
||||||
@@ -135,6 +133,6 @@ functions:
|
|||||||
|------|------|---------|:--------:| ------- |-------------|---------|
|
|------|------|---------|:--------:| ------- |-------------|---------|
|
||||||
| infile | string| `string` | | | Name of the json input file to utilise | |
|
| infile | string| `string` | | | Name of the json input file to utilise | |
|
||||||
| input-file | [][DirektivFile](#direktiv-file)| `[]apps.DirektivFile` | | | File to create before running commands | |
|
| input-file | [][DirektivFile](#direktiv-file)| `[]apps.DirektivFile` | | | File to create before running commands | |
|
||||||
| worksheet-name | string| `string` | | `"Sheet1"`| Label for the worksheet created in the spreadsheet | |
|
| name | string| `string` | | `"Sheet1"`| Label for the worksheet created in the spreadsheet | |
|
||||||
|
|
||||||
|
|
||||||
|
18
swagger.yaml
18
swagger.yaml
@@ -68,7 +68,7 @@ paths:
|
|||||||
items:
|
items:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
worksheet-name:
|
name:
|
||||||
type: string
|
type: string
|
||||||
description: Label for the worksheet created in the spreadsheet
|
description: Label for the worksheet created in the spreadsheet
|
||||||
default: "Sheet1"
|
default: "Sheet1"
|
||||||
@@ -98,12 +98,11 @@ paths:
|
|||||||
input:
|
input:
|
||||||
out-filename: example.xlsx
|
out-filename: example.xlsx
|
||||||
sheets:
|
sheets:
|
||||||
- sheet:
|
- name: "TestSpreadsheet"
|
||||||
worksheet-name: "TestSpreadsheet"
|
input-file:
|
||||||
input-file:
|
- name: input.json
|
||||||
- name: input.json
|
data: |
|
||||||
data: |
|
jq(.input)
|
||||||
jq(.input)
|
|
||||||
- title: Use jq to add a parent key 'input' containing array of objects
|
- title: Use jq to add a parent key 'input' containing array of objects
|
||||||
content: |-
|
content: |-
|
||||||
- id: export-xlsx
|
- id: export-xlsx
|
||||||
@@ -113,8 +112,7 @@ paths:
|
|||||||
input:
|
input:
|
||||||
out-filename: example.xlsx
|
out-filename: example.xlsx
|
||||||
sheets:
|
sheets:
|
||||||
- sheet:
|
- name: "TestSpreadsheet"
|
||||||
worksheet-name: "TestSpreadsheet"
|
|
||||||
input-file:
|
input-file:
|
||||||
- name: input.json
|
- name: input.json
|
||||||
data: |
|
data: |
|
||||||
@@ -127,7 +125,7 @@ paths:
|
|||||||
- action: foreach
|
- action: foreach
|
||||||
loop: .Sheets
|
loop: .Sheets
|
||||||
#exec: /bin/json2excel -inputJson {{- if eq (deref .Infile) "" }} "input.json" {{- else }} {{ .Infile }} {{- end }} -worksheetName "{{ .WorksheetName }}" -outputFilename '{{ .OutFilename }}'
|
#exec: /bin/json2excel -inputJson {{- if eq (deref .Infile) "" }} "input.json" {{- else }} {{ .Infile }} {{- end }} -worksheetName "{{ .WorksheetName }}" -outputFilename '{{ .OutFilename }}'
|
||||||
exec: /bin/json2excel -inputJson {{- if eq (deref .Item.Infile) "" }} "input.json" {{- else }} {{ .Item.Infile }} {{- end }} -worksheetName "{{ .Item.WorksheetName }}" -outputFilename '{{ .OutFilename }}'
|
exec: /bin/json2excel -inputJson {{- if eq (deref .Item.Infile) "" }} "input.json" {{- else }} {{ .Item.Infile }} {{- end }} -worksheetName "{{ .Item.Name }}" -outputFilename '{{ .OutFilename }}'
|
||||||
silent: false
|
silent: false
|
||||||
print: true
|
print: true
|
||||||
- action: exec
|
- action: exec
|
||||||
|
Reference in New Issue
Block a user