Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 87 lines (59 sloc) 1.76 KB
#!/usr/bin/env node
var post_gist = require("./lib/post")
, nopt = require("nopt")
var help = docstring(function help() {/*
gist-put [-p|--public] [-a|--anonymous] [-d|--description 'short description'] [-o|--open] [file1] [file2] [file3]
-p, --public
Make a public gist on your account (It's secret by default). Needs to
read your authentication details from `git credential fill`.
-a, --anonymous
Make an anonymous gist
-d, --description <string>:
The value of this option, if present, is the description of the gist.
-o, --open
Open the url in the default browser after creation.
-b --blocks
Prints the bl.ocks.org url instead of the gist url, or, if you've
specified --open, opens the bl.ocks.org url instead of the gist url.
-r --requirebin
Prints the requirebin url instead of the gist url, or, if you've
specified --open, opens the bl.ocks.org url instead of the gist url.
*/})
// attribution due to chrisdickinson
function docstring(fn) {
fn = fn + ''
return fn.slice(fn.indexOf('\n') + 1, fn.lastIndexOf('*/'))
}
var opts = {
'public': Boolean
, 'anonymous': Boolean
, 'open': Boolean
, 'description': String
, 'help': Boolean
, 'blocks': Boolean
, 'requirebin': Boolean
}
shorthands = {
'p': '--public'
, 'a': '--anonymous'
, 'o': '--open'
, 'd': '--description'
, 'h': '--help'
, 'b': '--blocks'
, 'r': '--requirebin'
}
var args = nopt(opts, shorthands, process.argv)
var options = {}
, files
for(var key in args) {
if(key === 'argv') {
continue
}
options[key] = args[key]
}
files = args.argv.remain
if(files.length === 0 || args.help) {
process.stderr.write(help)
process.exit(0)
}
post_gist(files, options)