Skip to content

Commit

Permalink
add v2 backwards compatibility shell scripts for automation purposes
Browse files Browse the repository at this point in the history
  • Loading branch information
consolethinks committed Jun 28, 2024
1 parent 60e2957 commit ec0bef1
Show file tree
Hide file tree
Showing 10 changed files with 144 additions and 6 deletions.
40 changes: 34 additions & 6 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,48 @@ builds:
dir: ./cmd/
goos:
- linux
- windows
- darwin
goarch:
- amd64
main: .
binary: scicat-cli
- id: "scicat-cli-win"
flags:
- -trimpath
ldflags:
- "-s -w -X 'github.com/paulscherrerinstitute/scicat/cmd/commands.VERSION={{.Version}}'"
env:
- CGO_ENABLED=0
dir: ./cmd/
goos:
- windows
goarch:
- amd64
main: .
binary: scicat-cli


archives:
- format: tar.gz
- id: scicat-cli
format: tar.gz
builds:
- scicat-cli
wrap_in_directory: true
name_template: >-
{{ .ProjectName }}_
{{- .Version }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
files:
- src: cmd/scripts/*
strip_parent: true
- id: scicat-cli-win
format: zip
builds:
- scicat-cli-win
wrap_in_directory: true
name_template: >-
{{ .ProjectName }}_
Expand All @@ -50,10 +82,6 @@ archives:
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
# use zip for windows archives
format_overrides:
- goos: windows
format: zip
changelog:
sort: asc
Expand Down
22 changes: 22 additions & 0 deletions cmd/scripts/argconverter.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

function arg_conversion {
args=("$@")

# Initialize an empty array to hold the modified arguments
modified_args=()

for arg in "${args[@]}"
do
# Check if the argument starts with a single hyphen and is not a double hyphen
if [[ $arg == -[!-]* ]]; then
# Modify the argument to start with a double hyphen
modified_args+=(--"${arg:1}")
else
# Add the argument as is
modified_args+=("$arg")
fi
done

echo "${modified_args[@]}"
}
11 changes: 11 additions & 0 deletions cmd/scripts/datasetArchiver
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

# shellcheck source=/dev/null
source "$SCRIPT_DIR"/argconverter.sh

modified_args=$(arg_conversion "$@")

# Call `echo` with the modified arguments
"$SCRIPT_DIR"/scicat-cli datasetArchiver "${modified_args[@]}"
11 changes: 11 additions & 0 deletions cmd/scripts/datasetCleaner
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

# shellcheck source=/dev/null
source "$SCRIPT_DIR"/argconverter.sh

modified_args=$(arg_conversion "$@")

# Call `echo` with the modified arguments
"$SCRIPT_DIR"/scicat-cli datasetCleaner "${modified_args[@]}"
11 changes: 11 additions & 0 deletions cmd/scripts/datasetGetProposal
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

# shellcheck source=/dev/null
source "$SCRIPT_DIR"/argconverter.sh

modified_args=$(arg_conversion "$@")

# Call `echo` with the modified arguments
"$SCRIPT_DIR"/scicat-cli datasetGetProposal "${modified_args[@]}"
11 changes: 11 additions & 0 deletions cmd/scripts/datasetIngestor
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

# shellcheck source=/dev/null
source "$SCRIPT_DIR"/argconverter.sh

modified_args=$(arg_conversion "$@")

# Call `echo` with the modified arguments
"$SCRIPT_DIR"/scicat-cli datasetIngestor "${modified_args[@]}"
11 changes: 11 additions & 0 deletions cmd/scripts/datasetPublishData
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

# shellcheck source=/dev/null
source "$SCRIPT_DIR"/argconverter.sh

modified_args=$(arg_conversion "$@")

# Call `echo` with the modified arguments
"$SCRIPT_DIR"/scicat-cli datasetPublishData "${modified_args[@]}"
11 changes: 11 additions & 0 deletions cmd/scripts/datasetPublishDataRetrieve
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

# shellcheck source=/dev/null
source "$SCRIPT_DIR"/argconverter.sh

modified_args=$(arg_conversion "$@")

# Call `echo` with the modified arguments
"$SCRIPT_DIR"/scicat-cli datasetPublishDataRetrieve "${modified_args[@]}"
11 changes: 11 additions & 0 deletions cmd/scripts/datasetRetriever
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

# shellcheck source=/dev/null
source "$SCRIPT_DIR"/argconverter.sh

modified_args=$(arg_conversion "$@")

# Call `echo` with the modified arguments
"$SCRIPT_DIR"/scicat-cli datasetRetriever "${modified_args[@]}"
11 changes: 11 additions & 0 deletions cmd/scripts/waitForJobFinished
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

# shellcheck source=/dev/null
source "$SCRIPT_DIR"/argconverter.sh

modified_args=$(arg_conversion "$@")

# Call `echo` with the modified arguments
"$SCRIPT_DIR"/scicat-cli waitForJobFinished "${modified_args[@]}"

0 comments on commit ec0bef1

Please sign in to comment.