diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 0cd25fa..c68bfef 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -11,7 +11,7 @@ # Now you can run GoReleaser at the root of your repository: `goreleaser release` # For dry run, see https://goreleaser.com/quick-start/#dry-run -version: 1 +version: 2 before: hooks: @@ -54,7 +54,15 @@ archives: format_overrides: - goos: windows format: zip - + - id: scicat-cli-scripts + format: tar.gz + wrap_in_directory: true + name_template: >- + {{ .ProjectName }}_V2Scripts_{{- .Version }} + files: + - src: cmd/scripts/* + strip_parent: true + meta: true changelog: sort: asc filters: diff --git a/README.md b/README.md index cbd023e..8765236 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,23 @@ Tools are compiled for the following architectures: These can be cross-compiled from any system. +### V3 Changes +The separate executables (like `datasetIngestor`, `datasetRetriever`...) were combined into one `scicat-cli` executable, with each executable's features available as commands given as the first parameter to this executable. + +These commands bear the same names as the former executables. The general syntax change is that if you called `./[COMMAND] [flags]` before, now it's `./scicat-cli [COMMAND] [flags]`. + + Furthermore, the use of single hyphen, multi-letter flags is now discontinued, as it went against general convention. So, in practical terms, `-[long_flag_name]` and `--[long_flag_name]` were both accepted, but now only the latter is accepted. + +### Backwards compatibility with v2 +A set of shell scripts are included with releases that are compatible with Linux and Mac executables in order to maintain compatibility with preexisting automation scripts. +As these are written in BASH, Windows is not supported unless WSL2 is used. + +Usage informations: + - The scripts can be found on the [Releases](https://github.com/paulscherrerinstitute/scicat-cli/releases) page, under scicat-cli_V2Scripts-[VERSION].tar.gz + - Just extract the archive into the folder with the scicat-cli executable + - The scripts and the scicat-cli executable **must** be kept in the **same folder** for them to work + - The scripts will still accept single hyphen flags as well + ## Deployment PSI deploys tools to the following locations. diff --git a/cmd/scripts/common.sh b/cmd/scripts/common.sh new file mode 100644 index 0000000..96789ee --- /dev/null +++ b/cmd/scripts/common.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# shellcheck disable=SC2034 +RED='\033[0;31m' +YEL='\033[1;33m' +NC='\033[0m' # No Color +WARN_STRING="${RED}Warning!${YEL} These backwards compatibilty scripts will soon be deprecated!${NC} Please use, or update your code to use, the scicat-cli executable directly." + +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[@]}" +} diff --git a/cmd/scripts/datasetArchiver b/cmd/scripts/datasetArchiver new file mode 100755 index 0000000..3a23081 --- /dev/null +++ b/cmd/scripts/datasetArchiver @@ -0,0 +1,10 @@ +#!/bin/bash + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +# shellcheck source=/dev/null +source "$SCRIPT_DIR"/common.sh + +echo -e "${WARN_STRING}" +modified_args=$(arg_conversion "$@") +"$SCRIPT_DIR"/scicat-cli datasetArchiver "${modified_args[@]}" diff --git a/cmd/scripts/datasetCleaner b/cmd/scripts/datasetCleaner new file mode 100755 index 0000000..f833a44 --- /dev/null +++ b/cmd/scripts/datasetCleaner @@ -0,0 +1,10 @@ +#!/bin/bash + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +# shellcheck source=/dev/null +source "$SCRIPT_DIR"/common.sh + +echo -e "${WARN_STRING}" +modified_args=$(arg_conversion "$@") +"$SCRIPT_DIR"/scicat-cli datasetCleaner "${modified_args[@]}" diff --git a/cmd/scripts/datasetGetProposal b/cmd/scripts/datasetGetProposal new file mode 100755 index 0000000..ae64150 --- /dev/null +++ b/cmd/scripts/datasetGetProposal @@ -0,0 +1,10 @@ +#!/bin/bash + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +# shellcheck source=/dev/null +source "$SCRIPT_DIR"/common.sh + +echo -e "${WARN_STRING}" +modified_args=$(arg_conversion "$@") +"$SCRIPT_DIR"/scicat-cli datasetGetProposal "${modified_args[@]}" diff --git a/cmd/scripts/datasetIngestor b/cmd/scripts/datasetIngestor new file mode 100755 index 0000000..eaa75d2 --- /dev/null +++ b/cmd/scripts/datasetIngestor @@ -0,0 +1,10 @@ +#!/bin/bash + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +# shellcheck source=/dev/null +source "$SCRIPT_DIR"/common.sh + +echo -e "${WARN_STRING}" +modified_args=$(arg_conversion "$@") +"$SCRIPT_DIR"/scicat-cli datasetIngestor "${modified_args[@]}" diff --git a/cmd/scripts/datasetPublishData b/cmd/scripts/datasetPublishData new file mode 100644 index 0000000..da40698 --- /dev/null +++ b/cmd/scripts/datasetPublishData @@ -0,0 +1,10 @@ +#!/bin/bash + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +# shellcheck source=/dev/null +source "$SCRIPT_DIR"/common.sh + +echo -e "${WARN_STRING}" +modified_args=$(arg_conversion "$@") +"$SCRIPT_DIR"/scicat-cli datasetPublishData "${modified_args[@]}" diff --git a/cmd/scripts/datasetPublishDataRetrieve b/cmd/scripts/datasetPublishDataRetrieve new file mode 100644 index 0000000..8cc56d0 --- /dev/null +++ b/cmd/scripts/datasetPublishDataRetrieve @@ -0,0 +1,10 @@ +#!/bin/bash + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +# shellcheck source=/dev/null +source "$SCRIPT_DIR"/common.sh + +echo -e "${WARN_STRING}" +modified_args=$(arg_conversion "$@") +"$SCRIPT_DIR"/scicat-cli datasetPublishDataRetrieve "${modified_args[@]}" diff --git a/cmd/scripts/datasetRetriever b/cmd/scripts/datasetRetriever new file mode 100755 index 0000000..715e287 --- /dev/null +++ b/cmd/scripts/datasetRetriever @@ -0,0 +1,10 @@ +#!/bin/bash + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +# shellcheck source=/dev/null +source "$SCRIPT_DIR"/common.sh + +echo -e "${WARN_STRING}" +modified_args=$(arg_conversion "$@") +"$SCRIPT_DIR"/scicat-cli datasetRetriever "${modified_args[@]}" diff --git a/cmd/scripts/waitForJobFinished b/cmd/scripts/waitForJobFinished new file mode 100755 index 0000000..32e883d --- /dev/null +++ b/cmd/scripts/waitForJobFinished @@ -0,0 +1,10 @@ +#!/bin/bash + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +# shellcheck source=/dev/null +source "$SCRIPT_DIR"/common.sh + +echo -e "${WARN_STRING}" +modified_args=$(arg_conversion "$@") +"$SCRIPT_DIR"/scicat-cli waitForJobFinished "${modified_args[@]}"