Skip to content
Merged
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
61 changes: 56 additions & 5 deletions ada/ada
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ usage() {
--unstage --from-file <file-list>
Release files in the list.

--stat-request <request-id>
--stat-request <request-id>
Show status of bulk request for given request-id

--events <channel-name> <path-to-follow> [--resume] [--force] [--recursive] [--timeout s]
Expand Down Expand Up @@ -301,7 +301,7 @@ set_defaults() {
# The ADA_VERSION value will be automatically updated by Github action Update-ada-version.yml
# For a release, it will contain the version number (like v3.1).
# For a branch, it will contain the branch name.
ADA_VERSION="master"
ADA_VERSION="125-args-error-message"
args=
api=
debug=false
Expand Down Expand Up @@ -407,6 +407,7 @@ get_args() {
exit 1
;;
--tokenfile )
check_arg "tokenfile" $2
auth_method=tokenfile
tokenfile="$2"
#Check if authentication file is passed as argument
Expand Down Expand Up @@ -449,6 +450,7 @@ get_args() {
shift
;;
--api )
check_arg "api" $2
api="$2"
shift ; shift
;;
Expand All @@ -462,55 +464,68 @@ get_args() {
;;
--list )
command='list'
check_arg $command $2
path="$2"
shift ; shift
;;
--longlist )
command='longlist'
if [ "$2" = "--from-file" ] ; then
check_arg "from-file" $3
$debug && echo "Reading list '$3'"
pathlist=$(<"$3")
shift ; shift ; shift
else
check_arg "longlist" $2
pathlist="$2"
shift ; shift
fi
;;
--stat )
check_arg "stat" $2
command='stat'
path="$2"
shift ; shift
;;
--mkdir )
command='mkdir'
check_arg $command $2
path="$2"
shift ; shift
;;
--mv )
command='mv'
check_arg $command $2
check_arg $command $3
path="$2"
destination="$3"
shift ; shift ; shift
;;
--delete )
command='delete'
check_arg $command $2
path="$2"
shift ; shift
;;
--setlabel )
command='setlabel'
check_arg $command $2
check_arg $command $3
path="$2"
label="$3"
shift ; shift ; shift
;;
--rmlabel )
command='rmlabel'
check_arg $command $2
check_arg $command $3
path="$2"
label="$3"
shift ; shift ; shift
;;
--lslabel )
command='lslabel'
check_arg $command $2
path="$2"
shift ; shift
# Optinal argument: a label the user wants to see.
Expand All @@ -527,15 +542,18 @@ get_args() {
;;
--findlabel )
command='findlabel'
check_arg $command $2
check_arg $command $3
path=$(echo "$2" | sed 's:/*$::')
regex="$3"
shift ; shift ; shift
;;
--setxattr )
command='setxattr'
check_arg $command $2
path="$2"
shift ; shift
# Optinal argument: filename containing the attributes (or - for stdin)
# Optional argument: filename containing the attributes (or - for stdin)
case $1 in
--* | '' )
# Next argument is another option or absent; not a file name.
Expand All @@ -562,6 +580,7 @@ get_args() {
;;
--lsxattr )
command='lsxattr'
check_arg $command $2
path="$2"
shift ; shift
# Optinal argument: name of an attribute
Expand All @@ -578,6 +597,9 @@ get_args() {
;;
--findxattr )
command='findxattr'
check_arg $command $2
check_arg $command $3
check_arg $command $4
# Strip trailing slashes
path=$(echo "$2" | sed 's:/*$::')
attribute_name="$3"
Expand All @@ -586,27 +608,35 @@ get_args() {
;;
--rmxattr )
command='rmxattr'
check_arg $command $2
if [[ $3 != '--all' ]] ; then
check_arg $command $3
fi
path="$2"
attribute_name="$3"
shift ; shift ; shift
;;
--checksum )
command='checksum'
if [ "$2" = "--from-file" ] ; then
check_arg "from-file" $3
pathlist=$(<"$3")
shift ; shift ; shift
else
check_arg "checksum" $2
pathlist="$2"
shift ; shift
fi
;;
--stage )
command='stage'
if [[ $2 =~ ^--from-?file ]] ; then
check_arg "from-file" $3
from_file=true
pathlist=$(<"$3")
shift ; shift ; shift
else
check_arg "stage" $2
from_file=false
pathlist="$2"
shift ; shift
Expand All @@ -615,32 +645,40 @@ get_args() {
--unstage )
command='unstage'
if [[ $2 =~ ^--from-?file ]] ; then
check_arg "from-file" $3
from_file=true
pathlist=$(<"$3")
shift ; shift ; shift
else
check_arg "unstage" $2
from_file=false
pathlist="$2"
shift ; shift
fi
;;
--request-id )
check_arg "request_id" $2
request_id="$2"
shift ; shift
;;
--stat-request )
command='stat-request'
check_arg $command $2
request_id="$2"
shift ; shift
;;
--events )
command='events'
check_arg $command $2
check_arg $command $3
channel_name="$2"
path="$3"
shift ; shift ; shift
;;
--report-staged )
command='report-staged'
check_arg $command $2
check_arg $command $3
channel_name="$2"
path="$3"
shift ; shift ; shift
Expand All @@ -658,12 +696,14 @@ get_args() {
shift
;;
--lifetime )
check_arg "lifetime" $2
arg="$2"
lifetime=${arg::${#arg} -1}
lifetime_unit=${arg: ${#arg}-1}
shift ; shift
;;
--timeout )
check_arg "timeout" $2
channel_timeout="$2"
shift ; shift
;;
Expand All @@ -675,14 +715,16 @@ get_args() {
;;
* )
# This must be a channel name
check_arg $command $2
channel_name="$2"
shift
;;
esac
shift
;;
--delete-channel )
command='delete-channel'
command='delete-channel'
check_arg $command $2
channel_name="$2"
shift ; shift
;;
Expand All @@ -694,6 +736,7 @@ get_args() {
;;
* )
# This must be a poolgroup
check_arg $command $2
poolgroup="$2"
shift
;;
Expand Down Expand Up @@ -741,6 +784,15 @@ get_args() {
# Define internal functions ada needs
#

check_arg() {
option=$1
arg=$2
if [[ $arg == --* || $arg == '' ]]; then
echo 1>&2 "ERROR: option --$option requires next argument"
exit 1
fi
}


view_token() {
local token="$1"
Expand Down Expand Up @@ -783,7 +835,6 @@ view_token() {
}



validate_expiration_timestamp () {
local exp_unix="$1" # Expiration timestamp (unix format)
local token_debug_info="$2" # Additional info for error message
Expand Down