Class: VimGolf::CLI
- Inherits:
-
Thor
- Object
- Thor
- VimGolf::CLI
- Includes:
- Thor::Actions
- Defined in:
- lib/vimgolf/ui.rb,
lib/vimgolf/cli.rb
Defined Under Namespace
Classes: UI
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
Instance Method Details
#local(infile, outfile) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/vimgolf/cli.rb', line 84 def local(infile, outfile) # make sure our files are sane if !(File.file?(infile) and File.file?(outfile)) VimGolf.ui.error "INFILE and OUTFILE must exist and be regular files." exit 1 end challenge = Challenge.new(infile) # use the filename as id challenge.local(infile, outfile) play(challenge) end |
#put(id) ⇒ Object
69 70 71 72 73 74 75 76 77 |
# File 'lib/vimgolf/cli.rb', line 69 def put(id) FileUtils.mkdir_p Config.put_path VimGolf.ui.warn "Downloading Vimgolf challenge: #{id}" VimGolf::Challenge.path(Config.put_path) challenge = Challenge.new(id) challenge.download play(challenge) end |
#setup ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/vimgolf/cli.rb', line 44 def setup VimGolf.ui.info "\nLet's setup your VimGolf key..." VimGolf.ui.warn "1) Open vimgolf.com in your browser." VimGolf.ui.warn "2) Click \"Sign in with Twitter\"." VimGolf.ui.warn "3) Once signed in, copy your key (black box, top right)." key = VimGolf.ui.ask "\nPaste your VimGolf key:" if key =~ /[\w\d]{32}/ FileUtils.mkdir_p Config.path FileUtils.mkdir_p Config.put_path Config.save({'key' => key}) VimGolf.ui.info "Saved. Happy golfing!" else VimGolf.ui.error "Invalid key, please double check your key on vimgolf.com" end end |