gs

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

commit c50effd2e8f2e838951b812a4719d97e512e70e5
parent 1c3dd4826a76be4fd1cecd70000aead78fd21fd6
Author: Ed van Bruggen <edvb54@gmail.com>
Date:   Sun, 30 Jul 2017 16:20:50 -0700

-g option to change GitHub URL

Diffstat:
README.md | 6+++++-
config.def.h | 9+++++----
gs.1 | 6+++++-
gs.c | 8+++++---
4 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/README.md b/README.md @@ -2,7 +2,7 @@ ## SYNOPSIS -**gs** [**-pPhv**] [**-d** *DESCRIPTION*] [**-f** *FILENAME*] [**-u** *USER*[: *PASSWORD*] | **-U**] [*FILES* ...] +**gs** [**-pPhv**] [**-d** *DESCRIPTION*] [**-f** *FILENAME*] [**-g** *GITHUB\_URL*] [**-u** *USER*[: *PASSWORD*] | **-U**] [*FILES* ...] ## DESCRIPTION @@ -18,6 +18,10 @@ Set Gist description Set file name when reading from `stdin` +#### -g GITHUB_URL + +Change the GitHub API URL + #### -p Make Gist private diff --git a/config.def.h b/config.def.h @@ -1,4 +1,5 @@ -char *desc = ""; /* default gist description */ -char *fname = NULL; /* default gist filename when reading from stdin */ -char *user = NULL; /* default user, password can be given after colon */ -int pub = 1; /* 0: private need link to view, 1: public anyone can find */ +char *desc = ""; /* Gist description */ +char *fname = NULL; /* Gist filename when reading from stdin */ +char *user = NULL; /* GitHub user, password can be given after colon */ +char *ghurl = "https://api.github.com/gists"; /* default GitHub URL to post gists to */ +int pub = 1; /* 0: private need link to view, 1: public anyone can find */ diff --git a/gs.1 b/gs.1 @@ -6,7 +6,7 @@ gs - painless gist creator .PP .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 ...] +\fBgs\fP [\fB-pPhv\fP] [\fB-d\fP \fIDESCRIPTION\fP] [\fB-f\fP \fIFILENAME\fP] [\fB-g\fP \fIGITHUB_URL\fP] [\fB-u\fP \fIUSER\fP[:\fIPASSWORD\fP] | \fB-U\fP] [\fIFILES\fP ...] .PP .SH DESCRIPTION Easy way to create GitHub Gists through the command line. @@ -21,6 +21,10 @@ Easy way to create GitHub Gists through the command line. \fRSet file name when reading from `\f[CR]stdin\fP' .PP .TP +\fB-g\fP \fIGITHUB_URL\fP +\fRChange the GitHub API URL +.PP +.TP \fB-p \fRMake Gist private .PP diff --git a/gs.c b/gs.c @@ -11,7 +11,6 @@ #include "util.h" /* defines */ -#define GIST_URL "https://api.github.com/gists" #define LBUF_SIZE 1024 /* TODO remove BUF_SIZEs */ #define BUF_SIZE 100000 @@ -67,7 +66,7 @@ http_post(char *content, long okcode) } /* set cURL options */ - curl_easy_setopt(curl, CURLOPT_URL, GIST_URL); + curl_easy_setopt(curl, CURLOPT_URL, ghurl); curl_easy_setopt(curl, CURLOPT_USERAGENT, "gs/"VERSION); if (user) { if (strchr(user, ':')) { @@ -175,7 +174,7 @@ gs_new(char *files[], int filec) static void usage(const int eval) { - die(eval, "usage: %s [-pPhv] [-d DESCRIPTION] [-f FILENAME]\n" + die(eval, "usage: %s [-pPhv] [-d DESCRIPTION] [-f FILENAME] [-g GITHUB_URL]\n" " [-u USER[:PASSWORD] | -U] [FILES ...]", argv0); } @@ -189,6 +188,9 @@ main(int argc, char *argv[]) case 'f': fname = EARGF(usage(1)); break; + case 'g': + ghurl = EARGF(usage(1)); + break; case 'p': pub = 0; break;