commit f8b8653d30a32bba03001d6b199d52bfbe7501a4 from: Oliver Lowe date: Thu Oct 17 09:28:46 2024 UTC bin/bbsnip: new command to share code snippets at work Because good luck fucking around with either Microsoft Teams and Jira! commit - ebe2df371c030ab01af2519635048f5db6192a70 commit + f8b8653d30a32bba03001d6b199d52bfbe7501a4 blob - /dev/null blob + 92a92f33a39abea824c0a2c001ce031087e7263f (mode 755) --- /dev/null +++ bin/bbsnip @@ -0,0 +1,28 @@ +#!/bin/sh + +usage='usage: bbsnip [file ...]' + +# Snippets overview | Bitbucket Cloud +# https://support.atlassian.com/bitbucket-cloud/docs/snippets-overview/ +# https://developer.atlassian.com/bitbucket/api/2/reference/resource/snippets + +# https://docs.atlassian.com +confpath="$HOME/.config/atlassian/basicauth" +if ! test -f $confpath +then + echo "load auth from $confpath: no such file" + exit 1 +fi +auth=`sed 1q $home/.config/atlassian/basicauth` + +files="-F file=<-" # standard input +if test $1 +then + files="" + for f in $@ + do + files="-F file=@$f $files" + done +fi + +curl -s -u $auth https://api.bitbucket.org/2.0/snippets $files blob - /dev/null blob + 9fd5321c6128623b74335d95bcf9829183cf977d (mode 644) --- /dev/null +++ man/bbsnip.1 @@ -0,0 +1,23 @@ +.Dd +.Dt BBSNIP 1 +.Sh NAME +.Nm bbsnip +.Nd create a snippet on BitBucket +.Sh SYNOPSIS +.Nm +.Op Ar +.Sh DESCRIPTION +The +.Nm +utility reads from the named files +or the standard input if none is specified, +and creates a snippet from its contents on the BitBucket hosted service. +A URL to the snippet is printed on success. +.Sh FILES +.Pa Ev /.config/atlassian/basicauth +.Sh EXIT STATUS +.Ex +.Sh SEE ALSO +.Xr curl 1 , +.Lk https://support.atlassian.com/bitbucket-cloud/docs/snippets-overview/ Bitbucket's Snippets overview +.Lk https://developer.atlassian.com/bitbucket/api/2/reference/ Bitbucket HTTP API reference