module GradesFirst::CliHelper

Helper methods used across multiple Thor CLI commands and subcommands.

Private Instance Methods

execute(klass, *args) click to toggle source

Executes a command that conforms to the GradesFirst Command pattern interface.

# File lib/gradesfirst/cli_helper.rb, line 9
def execute(klass, *args)
  command = klass.new
  command.execute(*args)
  say command.response
end
set_pivotal_tracker_api_token() click to toggle source

Set the PivotalTracker api token to authenticate the current user. If the user is access PivotalTracker for the first time then they will be prompted to enter their api token and it will be saved for later use.

# File lib/gradesfirst/cli_helper.rb, line 18
def set_pivotal_tracker_api_token
  file_name = "#{Dir.home}/.pivotal_tracker_api_key"
  if File.exists?(file_name)
    api_token = File.read(file_name)
  else
    api_token = ask('Enter your PivotalTracker API token:')
    File.open(file_name, 'w') do |file|
      file.write(api_token)
    end
  end

  PivotalTracker.api_token = api_token
end