Class: UndriveGoogle::CLI

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/undrive_google/cli.rb

Overview

Defines the CLI behavior & provides the Google Drive Session

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/undrive_google/cli.rb', line 7

def options
  @options
end

#parserObject (readonly)

Returns the value of attribute parser.



7
8
9
# File 'lib/undrive_google/cli.rb', line 7

def parser
  @parser
end

#sessionObject (readonly)

Returns the value of attribute session.



7
8
9
# File 'lib/undrive_google/cli.rb', line 7

def session
  @session
end

Instance Method Details

#liberate!Object



27
28
29
30
# File 'lib/undrive_google/cli.rb', line 27

def liberate!
  Options.instance.title = session.file.title if missing_title?
  CaptiveFile.instance.liberate!
end

#parse(args) ⇒ Object

Options specified on the command line are collected in *@options*.

Parameters:

  • args (ARGV)

Returns:

  • nil

Raises:



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/undrive_google/cli.rb', line 13

def parse(args)
  @options = Options.instance
  @parser = OptionParser.new do |parser|
    @options.define_options(parser)
    parser.parse!(args)
  end
  raise UndriveGoogle::Error, "file_id is required!" unless options.file_id
  raise UndriveGoogle::Error, "dir is required!" unless options.dir

  @session = Session.instance

  nil
end