Class: Weekdone::Cli::Command

Inherits:
Thor
  • Object
show all
Includes:
Weekdone::Cli
Defined in:
lib/weekdone/cli/command.rb

Constant Summary

Constants included from Weekdone::Cli

VERSION

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Weekdone::Cli

#build_client

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/weekdone/cli/command.rb', line 13

def self.exit_on_failure?
  true
end

Instance Method Details

#loginObject



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/weekdone/cli/command.rb', line 18

def 
  client = build_client

  puts "open URL to authorize:"
  puts client.authorization_request

  print "\ninput authorization code: "
  auth_code = STDIN.gets.chomp
  client.authorization_grant(auth_code)

  Credential.write_credential(client.token_hash)
end

#reportObject



32
33
34
35
36
37
38
# File 'lib/weekdone/cli/command.rb', line 32

def report
  client = build_client

  report = client.getReport
  Credential.write_credential(client.token_hash)
  Output.format(report, format: :json)
end

#teamsObject



41
42
43
44
45
46
47
# File 'lib/weekdone/cli/command.rb', line 41

def teams
  client = build_client

  teams = client.getAllTeams
  Credential.write_credential(client.token_hash)
  Output.format(teams, format: :json)
end

#typesObject



59
60
61
62
63
64
65
# File 'lib/weekdone/cli/command.rb', line 59

def types
  client = build_client

  types = client.getAllTypes
  Credential.write_credential(client.token_hash)
  Output.format(types, format: :json)
end

#usersObject



50
51
52
53
54
55
56
# File 'lib/weekdone/cli/command.rb', line 50

def users
  client = build_client

  users = client.getAllUsers
  Credential.write_credential(client.token_hash)
  Output.format(users, format: :json)
end