Method: Agave::Cli#check

Defined in:
lib/agave/cli.rb

#checkObject



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/agave/cli.rb', line 57

def check
  exit 0 if ENV['AGAVE_API_TOKEN']

  say 'Site token is not specified!'
  token = ask "Please paste your AgaveCMS site read-only API token:\n>"

  if !token || token.empty?
    puts 'Missing token'
    exit 1
  end

  File.open('.env', 'a') do |file|
    file.puts "AGAVE_API_TOKEN=#{token}"
  end

  say 'Token added to .env file.'

  exit 0
end