Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: backwards compatibility #86

Merged
merged 8 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
17 changes: 17 additions & 0 deletions README.md
minottic marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
28 changes: 28 additions & 0 deletions cmd/scripts/common.sh
Original file line number Diff line number Diff line change
@@ -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[@]}"
}
10 changes: 10 additions & 0 deletions cmd/scripts/datasetArchiver
Original file line number Diff line number Diff line change
@@ -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[@]}"
10 changes: 10 additions & 0 deletions cmd/scripts/datasetCleaner
Original file line number Diff line number Diff line change
@@ -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[@]}"
10 changes: 10 additions & 0 deletions cmd/scripts/datasetGetProposal
Original file line number Diff line number Diff line change
@@ -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[@]}"
10 changes: 10 additions & 0 deletions cmd/scripts/datasetIngestor
Original file line number Diff line number Diff line change
@@ -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[@]}"
10 changes: 10 additions & 0 deletions cmd/scripts/datasetPublishData
Original file line number Diff line number Diff line change
@@ -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[@]}"
10 changes: 10 additions & 0 deletions cmd/scripts/datasetPublishDataRetrieve
Original file line number Diff line number Diff line change
@@ -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[@]}"
10 changes: 10 additions & 0 deletions cmd/scripts/datasetRetriever
Original file line number Diff line number Diff line change
@@ -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[@]}"
10 changes: 10 additions & 0 deletions cmd/scripts/waitForJobFinished
Original file line number Diff line number Diff line change
@@ -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[@]}"