Skip to content

Instantly share code, notes, and snippets.

@uemuraj
Created October 2, 2012 23:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uemuraj/3824077 to your computer and use it in GitHub Desktop.
Save uemuraj/3824077 to your computer and use it in GitHub Desktop.
gist からファイルをダウンロードする簡単なスクリプト
#!/usr/bin/env groovy
import groovy.json.*
def options = new CliBuilder().with {
i(longOpt:'id', argName:'id', args:1, required:true, 'gist id')
p(longOpt:'prefix', argName:'prefix', args:1, 'save files to ${prefix}/...')
return it.parse(args)
}
if (options) {
def gist = new URL("https://api.github.com/gists/${options.id}").withReader('UTF-8') {
return new JsonSlurper().parse(it)
}
gist.files.each { key, value ->
file = new File(options.prefix ?: '.', value.filename)
println file
file.write(value.content.toString())
}
}
@uemuraj
Copy link
Author

uemuraj commented Oct 2, 2012

このスクリプトファイルはどうやってダウンロードしたら良いんでしょうね?

@uemuraj
Copy link
Author

uemuraj commented Mar 20, 2013

そうか、こんなものは必要なかったか...

http://d.hatena.ne.jp/kyon_mm/20130318/1363615979

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment