Class: GoogleDriveDotenv::CLI

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

Instance Method Summary collapse

Instance Method Details

#export(key) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/google_drive_dotenv/cli.rb', line 43

def export(key)
  config_path = File.expand_path(options['config'])

  unless File.exist?(config_path)
    raise "Please put #{config_path}"
  end

  auth_config = GoogleDrive::Config.new(config_path)
  auth_config.scope ||= GoogleDrive::Session::DEFAULT_SCOPE

  credentials = Google::Auth::UserRefreshCredentials.new(
    client_id: auth_config.client_id,
    client_secret: auth_config.client_secret,
    scope: auth_config.scope,
    redirect_uri: 'http://localhost:4567',
  )

  Launchy.open(credentials.authorization_uri)
  App.credentials = credentials
  App.output = options['output']
  App.key = key
  App.run!
end