Class: Exercism::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/cli.rb

Instance Method Summary collapse

Instance Method Details

#fetchObject



7
8
9
10
11
# File 'lib/cli.rb', line 7

def fetch
  require 'exercism'

  Exercism::Api.fetch_for(Exercism.user)
end

#loginObject



21
22
23
24
25
26
27
28
29
# File 'lib/cli.rb', line 21

def 
  require 'exercism'

  username = ask("Your GitHub username:")
  key = ask("Your exercism.io API key:")
  Exercism.(username, key)

  say("Your credentials have been written to #{Exercism.config.file}")
end

#logoutObject



32
33
34
35
36
# File 'lib/cli.rb', line 32

def logout
  require 'exercism'

  Exercism.config.delete
end

#submit(file) ⇒ Object



14
15
16
17
18
# File 'lib/cli.rb', line 14

def submit(file)
  require 'exercism'

  Exercism::Api.submit(file, {for: Exercism.user})
end

#whoamiObject



39
40
41
42
43
44
45
# File 'lib/cli.rb', line 39

def whoami
  require 'exercism'

  puts Exercism.user.github_username
rescue Errno::ENOENT
  puts "You are not logged in."
end