gs

Unnamed repository; edit this file 'description' to name the repository.
git clone git://edryd.org/gs
Log | Files | Refs | LICENSE

commit d626089d4fb66822f8ede5fbd87f1249b2bce3ff
parent 2421c0ce4f3dc5eb51dce55bf02992b5201d7fc2
Author: Ed van Bruggen <edvb54@gmail.com>
Date:   Fri, 28 Jul 2017 15:25:15 -0700

Change to md2roff man page generator

Diffstat:
Makefile | 7++++---
README.md | 114++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------
gs.1 | 175++++++++++++++++++++++++++++++++++++++++++++++---------------------------------
gs.c | 4++--
4 files changed, 176 insertions(+), 124 deletions(-)

diff --git a/Makefile b/Makefile @@ -1,4 +1,4 @@ -# gs - gist creator +# gs - painless gist creator # See LICENSE file for copyright and license details. include config.mk @@ -59,8 +59,9 @@ uninstall: man: @echo -n updating man page $(EXE).1 ... - @cat README.md | sed "s/# $(EXE)/# $(EXE) 1\n\n##NAME\n\n$(EXE) /" | \ - md2man-roff | sed "s/\\[la\]/\</" | sed "s/\\[ra\]/\>/" > $(EXE).1 + @cat README.md | \ + sed "1s/$(EXE)/$(EXE) 1 \"`date +%B\ %Y`\" \"$(EXE)\ $(VERSION)\"\n\n##NAME\n\n& /" | \ + md2roff - | sed "9s/]/]\ /g" | sed "9s/|/|\ /g" > $(EXE).1 @echo \ done .PHONY: all options clean install uninstall man diff --git a/README.md b/README.md @@ -1,85 +1,109 @@ -# gs - gist creator +# gs \- painless gist creator ## SYNOPSIS -`gs` [**-pPhv**] [**-d** *DESCRIPTION*] [**-f** *FILENAME*] [**-u** *USER*[:*PASSWORD*] | **-U**] [*FILES* ...] +**gs** [**-pPhv**] [**-d** *DESCRIPTION*] [**-f** *FILENAME*] [**-u** *USER*[: *PASSWORD*] | **-U**] [*FILES* ...] ## DESCRIPTION -Easy way to create Github gists with the command line. +Easy way to create GitHub Gists through the command line. ## OPTIONS -**-d** *DESCRIPTION* - Set gist description +#### -d DESCRIPTION -**-f** *FILENAME* - Set file name when reading from `stdin` +Set Gist description -**-p** - Make gist private +#### -f FILENAME -**-P** - Make gist public (default) +Set file name when reading from `stdin` -**-u** *USER*[:*PASSWORD*] - Change the Github account the gist will be posted under. A password can - given as well with a separating colon, a prompt is provided if not. +#### -p -**-U** - Post gist anonymously (default) +Make Gist private -**-h** - Print help and exit +#### -P -**-v** - Print version info and exit +Make Gist public (default) + +#### -u USER[:PASSWORD] + +Change the GitHub account the Gist will be posted under. A password can +given as well with a separating colon, a prompt is provided if not. + +#### -U + +Post Gist anonymously (default) + +#### -h + +Print help and exit + +#### -v + +Print version info and exit ## USAGE -Create a new gist of file `file.txt`: +Create a new Gist of file `file.txt`: - $ gs file.txt - https://gist.github.com/<new-id> +``` +$ gs file.txt +https://gist.github.com/<new-id> +``` -There is also support for multiple files in a single gist: +There is also support for multiple files in a single Gist: - $ gs README.md Makefile prog.c - https://gist.github.com/<new-id> +``` +$ gs README.md Makefile prog.c +https://gist.github.com/<new-id> +``` -Specify the gist's description: +Specify the Gist's description: - $ gs -d 'a cool shell script' script.sh - https://gist.github.com/<new-id> +``` +$ gs -d 'a cool shell script' script.sh +https://gist.github.com/<new-id> +``` -The gist's URL can be piped to other programs, for example to your clipboard to +The Gist's URL can be piped to other programs, for example to your clipboard to be pasted else where: - $ gs file.txt | xsel -bi +``` +$ gs file.txt | xsel -bi +``` -You can also create a new gist from `stdin`. The file name needs to be supplied +You can also create a new Gist from `stdin`. The file name needs to be supplied however: - $ cmd-which-errors | gs -f log.txt - https://gist.github.com/<new-id> +``` +$ cmd-which-errors | gs -f log.txt +https://gist.github.com/<new-id> +``` -New gists can be private as well: +New Gists can be private as well: - $ gs -p personal.info - https://gist.github.com/<new-id> +``` +$ gs -p personal.info +https://gist.github.com/<new-id> +``` -The new gist can be posted under a Github user, a prompt will ask for your +The new Gist can be posted under a GitHub user, a prompt will ask for your password: - $ gs -u your-name good-proj.rs - Github password: - https://gist.github.com/<new-id> +``` +$ gs -u your-name good-proj.rs +GitHub password: +https://gist.github.com/<new-id> +``` To skip the prompt your password can be supplied after a colon with the username: - $ gs -u your-name:password plugin/func.vim doc/func.txt - https://gist.github.com/<new-id> +``` +$ gs -u your-name:password plugin/func.vim doc/func.txt +https://gist.github.com/<new-id> +``` ## AUTHOR @@ -87,9 +111,9 @@ Ed van Bruggen <edvb54@gmail.com> ## SEE ALSO -See project page at: <http://edryd.org/projects/gs.html> +See project page at <http://edryd.org/projects/gs.html> -View source code at: <https://github.com/edvb/gs> +View source code at <https://github.com/edvb/gs> ## LICENSE diff --git a/gs.1 b/gs.1 @@ -1,118 +1,145 @@ -.TH gs 1 +.\" x-roff document +.do mso man.tmac +.TH gs 1 "July 2017" "gs 0.0.0" +.PP .SH NAME +gs - painless gist creator .PP -gs \- gist creator .SH SYNOPSIS +\fBgs\fP [\fB-pPhv\fP] [\fB-d\fP \fIDESCRIPTION\fP] [\fB-f\fP \fIFILENAME\fP] [\fB-u\fP \fIUSER\fP[:\fIPASSWORD\fP] | \fB-U\fP] [\fIFILES\fP ...] .PP -\fB\fCgs\fR [\fB\-pPhv\fP] [\fB\-d\fP \fIDESCRIPTION\fP] [\fB\-f\fP \fIFILENAME\fP] [\fB\-u\fP \fIUSER\fP[:\fIPASSWORD\fP] | \fB\-U\fP] [\fIFILES\fP ...] .SH DESCRIPTION +Easy way to create GitHub Gists through the command line. .PP -Easy way to create Github gists with the command line. .SH OPTIONS +.TP +\fB-d\fP \fIDESCRIPTION\fP +\fRSet Gist description .PP -\fB\-d\fP \fIDESCRIPTION\fP - Set gist description +.TP +\fB-f\fP \fIFILENAME\fP +\fRSet file name when reading from `\f[CR]stdin\fP' .PP -\fB\-f\fP \fIFILENAME\fP - Set file name when reading from \fB\fCstdin\fR +.TP +\fB-p +\fRMake Gist private .PP -\fB\-p\fP - Make gist private +.TP +\fB-P +\fRMake Gist public (default) .PP -\fB\-P\fP - Make gist public (default) +.TP +\fB-u\fP \fIUSER\fP[:\fIPASSWORD\fP] +\fRChange the GitHub account the Gist will be posted under. A password can given as well with a separating colon, a prompt is provided if not. .PP -\fB\-u\fP \fIUSER\fP[:\fIPASSWORD\fP] - Change the Github account the gist will be posted under. A password can - given as well with a separating colon, a prompt is provided if not. +.TP +\fB-U +\fRPost Gist anonymously (default) .PP -\fB\-U\fP - Post gist anonymously (default) +.TP +\fB-h +\fRPrint help and exit .PP -\fB\-h\fP - Print help and exit +.TP +\fB-v +\fRPrint version info and exit .PP -\fB\-v\fP - Print version info and exit .SH USAGE +Create a new Gist of file `\f[CR]file.txt\fP': .PP -Create a new gist of file \fB\fCfile.txt\fR: -.PP -.RS -.nf +.RS 4 +.EX + $ gs file.txt -https://gist.github.com/<new\-id> -.fi +https://gist.github.com/<new-id> + +.EE .RE .PP -There is also support for multiple files in a single gist: +There is also support for multiple files in a single Gist: .PP -.RS -.nf -$ gs file.txt list.txt readme.md -https://gist.github.com/<new\-id> -.fi +.RS 4 +.EX + +$ gs README.md Makefile prog.c +https://gist.github.com/<new-id> + +.EE .RE .PP -The gist's URL can be piped to other programs, for example to your clipboard to -be pasted else where: +Specify the Gist's description: .PP -.RS -.nf -$ gs file.txt | xsel \-bi -.fi +.RS 4 +.EX + +$ gs -d 'a cool shell script' script.sh +https://gist.github.com/<new-id> + +.EE .RE .PP -You can also create a new gist from \fB\fCstdin\fR\&. The file name needs to be supplied -however: +The Gist's URL can be piped to other programs, for example to your clipboard to be pasted else where: .PP -.RS -.nf -$ cmd\-which\-errors | gs \-f log.txt -https://gist.github.com/<new\-id> -.fi +.RS 4 +.EX + +$ gs file.txt | xsel -bi + +.EE .RE .PP -New gists can be private as well: +You can also create a new Gist from `\f[CR]stdin\fP'. The file name needs to be supplied however: .PP -.RS -.nf -$ gs \-p file.txt -https://gist.github.com/<new\-id> -.fi +.RS 4 +.EX + +$ cmd-which-errors | gs -f log.txt +https://gist.github.com/<new-id> + +.EE .RE .PP -The new gist can be posted under a Github user, a prompt will ask for your -password: +New Gists can be private as well: .PP -.RS -.nf -$ gs \-u your\-name file.txt -Github password: -https://gist.github.com/<new\-id> -.fi +.RS 4 +.EX + +$ gs -p personal.info +https://gist.github.com/<new-id> + +.EE .RE .PP -To skip the prompt your password can be supplied after a colon with the -username: +The new Gist can be posted under a GitHub user, a prompt will ask for your password: .PP -.RS -.nf -$ gs \-u your\-name:password file.txt -https://gist.github.com/<new\-id> -.fi +.RS 4 +.EX + +$ gs -u your-name good-proj.rs +GitHub password: +https://gist.github.com/<new-id> + +.EE .RE +.PP +To skip the prompt your password can be supplied after a colon with the username: +.PP +.RS 4 +.EX + +$ gs -u your-name:password plugin/func.vim doc/func.txt +https://gist.github.com/<new-id> + +.EE +.RE +.PP .SH AUTHOR +Ed van Bruggen <edvb54@gmail.com> .PP -Ed van Bruggen -\<edvb54@gmail.com\> .SH SEE ALSO +See project page at <http://edryd.org/projects/gs.html> .PP -See project page at: -\<http://edryd.org/projects/gs.html\> +View source code at <https://github.com/edvb/gs> .PP -View source code at: -\<https://github.com/edvb/gs\> .SH LICENSE -.PP zlib License diff --git a/gs.c b/gs.c @@ -67,7 +67,7 @@ http_post(char *content, long okcode) curl_easy_setopt(curl, CURLOPT_USERPWD, user); } else { curl_easy_setopt(curl, CURLOPT_USERNAME, user); - curl_easy_setopt(curl, CURLOPT_PASSWORD, getpass("Github password: ")); + curl_easy_setopt(curl, CURLOPT_PASSWORD, getpass("GitHub password: ")); } } curl_easy_setopt(curl, CURLOPT_POSTFIELDS, content); @@ -78,7 +78,7 @@ http_post(char *content, long okcode) curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &code); curl_easy_cleanup(curl); if (code != okcode) - die("%s: could not create gist: %s", argv0, resstr.ptr); + die("%s: could not create Gist: %s", argv0, resstr.ptr); return resstr; }