function newrepo --description 'Create new repos on multiple providers' argparse h/help p/private P/public s/srht g/github a/all d/description= -- $argv function help echo newrepo -- easily create sr.ht and github repos! echo USAGE echo \tnewrepo '[]' '[flags]' echo FLAGS echo \t-p/--private: set private echo \t-P/--public: set public echo \t-s/--srht: set srht provider echo \t-g/--github: set github provider echo \t-a/--all: set all providers echo \t-d/--description '[]': set optional description echo AUTHOR echo \tDaniel Fichtinger '' echo LICENSE echo \tMIT echo URL echo \t'git.sr.ht/~ficd/newrepo.fish' 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 hut git create $name --visibility $visibility $add end if set -lq _flag_g || set -lq _flag_a set -l add if set -lq _flag_d set add --description \"$_flag_d\" end gh repo create $name --disable-wiki "--$visibility" $add end end