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.



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

def options
  @options
end

#parserObject (readonly)

Returns the value of attribute parser.



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

def parser
  @parser
end

#sessionObject (readonly)

Returns the value of attribute session.



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

def session
  @session
end

Instance Method Details

#liberate!Object



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

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:



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

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