thor による対話型プロンプト
概要
何らかの方法でユーザーに flickr_id や flickr_apikey などを言ってもらいたいのですが、すべての引数のせいでそれほど長くて重い行にならないように、インストール コマンドでそれを行うことができれば幸いです。
だから次のようなもの
$ thor PhotoonRails:install
We're about to install your system.. blaa, blaa, blaa...
We have to know you're Flick ID, get i here http://idgettr.com/
Flickr ID: {here you should type your id}
We also has to know you're flick api key, make one here ...
API Key: {here you should type your key}
等々?アイデアはわかりましたか、そしてそれは実行できますか?
解決策
確かにそれは可能です!
あなたは質問を探しています。
例:
class PhotoonRails < Thor
desc "install", "install my cool stuff"
def install
say("We're about to install your system.. blaa, blaa, blaa... We have to know you're Flick ID, get i here http://idgettr.com")
flickr_id = ask("Flickr ID: ")
say("We also has to know you're flick api key, make one here ...")
flickr_api_key = ask("API Key: ")
# validate flickr creds
# do cool stuff
say("Complete!", GREEN)
end
end