Created
October 2, 2012 23:51
-
-
Save uemuraj/3824077 to your computer and use it in GitHub Desktop.
gist からファイルをダウンロードする簡単なスクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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()) | |
} | |
} |
そうか、こんなものは必要なかったか...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
このスクリプトファイルはどうやってダウンロードしたら良いんでしょうね?