dotfiles/.config/fish/functions/newrepo.fish

43 lines
1.3 KiB
Fish

function newrepo
argparse h/help p/private P/public s/srht g/github a/all d/description= -- $argv
function help
echo Help menu
end
if set -lq _flag_h || test (count $argv) -eq 0
help
return 0
end
# check that some visibility is set
set -l errors
set -l visibility
if not set -lq _flag_p && not set -lq _flag_P
set -a errors 'Visibility must be either public or private!'
else if set -lq _flag_p && not set -lq _flag_P
set visibility private
else if not set -lq _flag_p && set -lq _flag_P
set visibility public
else
set -a errors 'Only one visibility can be set!'
end
# check that a provider is set
if not set -lq _flag_a && not set -lq _flag_s && not set -lq _flag_g
set -a errors 'Provider must be set!'
else if set -lq _flag_a && set -lq _flag_s || set -lq _flag_g
set -a errors 'provider: all must be alone!'
end
set -l name $argv[1]
if test (count $errors) -ne 0
for i in $errors
echo ERROR: $i
end
help
return 1
end
if set -lq _flag_s || set -lq _flag_a
set -l add
if set -lq _flag_d
set add --description \"$_flag_d\"
end
echo hut git create $name --visibility $visibility $add
end
end