Class: Gdsh::Gdsh

Inherits:
DriveService show all
Includes:
CommandFactory
Defined in:
lib/gdsh.rb

Overview

Gdsh Class

Instance Method Summary collapse

Methods included from CommandFactory

#next_command, #parsed_inputs

Methods included from Commands

commands, interpret, puts_usage_header, usage

Methods inherited from DriveService

#authorize, #authorize_from_authorization_code, #authorize_from_refresh_token, #credentials_from_file, #credentials_from_stdin, #init_client, #initialize, #puts_refresh_error, #write_session_info_to_file

Constructor Details

This class inherits a constructor from DriveService

Instance Method Details

#clear_screenObject



29
30
31
# File 'lib/gdsh.rb', line 29

def clear_screen
  system('clear') || system('cls')
end

#init_shellObject



33
34
35
36
37
38
# File 'lib/gdsh.rb', line 33

def init_shell
  puts_banner
  authorize
  clear_screen
  puts_hint
end

#prints_promptObject



40
41
42
# File 'lib/gdsh.rb', line 40

def prints_prompt
  print 'gdsh> '.colorize(:light_blue)
end

#puts_bannerObject



19
20
21
22
23
# File 'lib/gdsh.rb', line 19

def puts_banner
  puts ''
  puts 'CLI tool to interface with Google Drive'.colorize(:green)
  puts '======================================='.colorize(:green)
end

#puts_hintObject



25
26
27
# File 'lib/gdsh.rb', line 25

def puts_hint
  puts 'Hint: type \'help\'.'.colorize(:green)
end

#shellObject

Command interpreter



47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/gdsh.rb', line 47

def shell
  init_shell

  loop do
    prints_prompt
    params = parsed_inputs
    command = next_command(params)
    command.new(@client, params).execute
    break if command.terminal?
  end

  write_session_info_to_file
end