11

ユーザーに 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}

等々?あなたはアイデアを得ることができますか?

4

2 に答える 2

20

確かにそれはできます!

を探していaskます。

例:

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
于 2011-01-05T15:17:24.810 に答える
5

色をシンボルとして設定することも可能

say "Caution!", :yellow
ask 'Agreed?', :bold

# Choose limit:
ask "We have noticed.", :green, limited_to: ['proceed', 'exit']

# Default value (possible without :blue)
ask 'Type app name', :blue, default: 'blog'

Thor で利用可能な色の完全なリストはこちら: http://www.rubydoc.info/github/wycats/thor/Thor/Shell/Color

于 2014-10-25T06:15:03.567 に答える