commit f8b8653d30a32bba03001d6b199d52bfbe7501a4 parent ebe2df371c030ab01af2519635048f5db6192a70 Author: Oliver Lowe <o@olowe.co> Date: Thu, 17 Oct 2024 20:28:46 +1100 bin/bbsnip: new command to share code snippets at work Because good luck fucking around with either Microsoft Teams and Jira! Diffstat:
| A | bin/bbsnip | | | 28 | ++++++++++++++++++++++++++++ |
| A | man/bbsnip.1 | | | 23 | +++++++++++++++++++++++ |
2 files changed, 51 insertions(+), 0 deletions(-)
diff --git a/bin/bbsnip b/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 diff --git a/man/bbsnip.1 b/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