diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..11883e3 --- /dev/null +++ b/Readme.md @@ -0,0 +1,23 @@ +# giteapi + +Creates ticket from command line + +Relies on a ~/.gitapi in bash format: + +```bash +server=url of gitea server +token=application token - read write access to issues +repo=name of repo +user=repo owner +``` + +## Usage: + +Interactive use: just run the script + +Non-interactive: script will accept following command line arguments: + + 1. client + 2. ticket title + 3. ticket body + diff --git a/giteacli.sh b/giteacli.sh index 5fcbf1b..2e8c5d3 100644 --- a/giteacli.sh +++ b/giteacli.sh @@ -14,9 +14,21 @@ test -r $configFile || { source $configFile -url=${server}/api/v1/ +url=${server}/api/v1/repos/$user/${repo}///issues -#curl -H "Authorization: Bearer ${token}" "${url}/repos/tom/Support/issues" -d '{"state": "close"}' -H 'Content-Type: application/json' -X GET -curl -H "Authorization: Bearer ${token}" "${url}/repos/tom/Support/issues" -X POST -d '{"title": "test"}' -H 'Content-Type: application/json' +if [ $# -gt 0 ] ; then + customer=$1 + title=$2 + text=$3 +else + read -p "customer: " customer + read -p "title: " title + read -p "text - use \\n for multiline " text +fi + +data="{ \"title\": \"$customer $title\",\"state\": \"open\",\"body\": \"$text\"}" +echo "$data" + +curl -H "Authorization: Bearer ${token}" "${url}" -X POST -H 'Content-Type: application/json' -d "$data" [ $? -eq 0 ] && { echo issue created ; } \ No newline at end of file