From 8c8a7c6a9c126728d81b651bfdd20a43a0599ca1 Mon Sep 17 00:00:00 2001
From: mancini <mancini@astron.nl>
Date: Mon, 6 Apr 2020 14:54:59 +0200
Subject: [PATCH] Add log collecting utils

Former-commit-id: 628a183200e3e8292dba97c8cb7e042197b12f76
Former-commit-id: a7c32fe99290735c5a106324a206c39cac6d7008
---
 steps/bulk_rename.cwl | 39 +++++++++++++++++++++++++++++++++++
 steps/collectlog.cwl  | 47 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 86 insertions(+)
 create mode 100644 steps/bulk_rename.cwl
 create mode 100644 steps/collectlog.cwl

diff --git a/steps/bulk_rename.cwl b/steps/bulk_rename.cwl
new file mode 100644
index 00000000..d75af405
--- /dev/null
+++ b/steps/bulk_rename.cwl
@@ -0,0 +1,39 @@
+class: CommandLineTool
+cwlVersion: v1.0
+$namespaces:
+  sbg: 'https://www.sevenbridges.com/'
+id: bulk_rename
+baseCommand:
+  - bash 
+  - bulk_rename.sh
+inputs:
+  - id: file_list
+    type: 'File[]'
+    inputBinding:
+      position: 0
+  - id: file_prefix
+    type: string
+  - id: file_suffix
+    type: string?
+outputs:
+  - id: output
+    type: 'File[]'
+    outputBinding:
+      glob: "tmp/$(inputs.file_prefix)*"
+label: bulk_rename
+requirements:
+  - class: InitialWorkDirRequirement
+    listing:
+      - entryname: bulk_rename.sh
+        entry: |
+          #!/bin/bash
+          set -e
+          FILE_LIST=("\${@}")
+          FILE_PREFIX=$(inputs.file_prefix)
+          FILE_SUFFIX=$(inputs.file_suffix === null ? '' : inputs.file_suffix)
+          mkdir tmp
+          for i in "\${!FILE_LIST[@]}"; do 
+            cp "\${FILE_LIST[\$i]}" "tmp/\${FILE_PREFIX}_\${i}\${FILE_SUFFIX}"
+          done
+        writable: false
+  - class: InlineJavascriptRequirement
diff --git a/steps/collectlog.cwl b/steps/collectlog.cwl
new file mode 100644
index 00000000..57ee22fd
--- /dev/null
+++ b/steps/collectlog.cwl
@@ -0,0 +1,47 @@
+class: CommandLineTool
+cwlVersion: v1.0
+$namespaces:
+  sbg: 'https://www.sevenbridges.com/'
+id: collectlog
+baseCommand:
+  - bash
+  - collect_logs.sh
+inputs:
+  - id: start_directory
+    type: Directory?
+  - id: log_files
+    type:
+      - File
+      - type: array
+        items: File
+    inputBinding:
+      position: 0
+  - id: sub_directory_name
+    type: string
+outputs: 
+  - id: log_dir
+    type: Directory
+    outputBinding:
+        glob: |
+          $(inputs.start_directory === null ? inputs.sub_directory_name: inputs.start_directory.basename)
+label: CollectLog
+requirements:
+  - class: InitialWorkDirRequirement
+    listing:
+      - entryname: collect_logs.sh
+        entry: |
+          #!/bin/bash
+          set -e
+          BASE_DIR="$(inputs.start_directory === null ? "" : inputs.start_directory.basename)"
+          SUB_DIR="$(inputs.sub_directory_name)"
+          if [ -z "$BASE_DIR" ]
+          then
+          OUTPUT_PATH=$SUB_DIR
+          else
+          OUTPUT_PATH=$BASE_DIR/$SUB_DIR
+          fi
+          echo $OUTPUT_PATH
+          mkdir -p $OUTPUT_PATH
+          cp -L $* $OUTPUT_PATH
+        writable: false
+  - class: InlineJavascriptRequirement
-- 
GitLab