Class: Aspera::Cli::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/aspera/cli/main.rb

Overview

Global objects shared with plugins

Constant Summary collapse

MEMBERS =
%i[options transfer config formatter persistency man_header].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeContext

Initialize all members to nil, so that they are defined and can be validated later



38
39
40
# File 'lib/aspera/cli/main.rb', line 38

def initialize
  MEMBERS.each{ |i| instance_variable_set(:"@#{i}", nil)}
end

Instance Attribute Details

#configPlugins::Config

Returns the configuration plugin, used by plugins to get configuration values and presets.

Returns:

  • (Plugins::Config)

    the configuration plugin, used by plugins to get configuration values and presets



34
# File 'lib/aspera/cli/main.rb', line 34

MEMBERS = %i[options transfer config formatter persistency man_header].freeze

#formatterFormatter

Returns the formatter, used by plugins to display results and messages.

Returns:

  • (Formatter)

    the formatter, used by plugins to display results and messages



34
# File 'lib/aspera/cli/main.rb', line 34

MEMBERS = %i[options transfer config formatter persistency man_header].freeze

#man_headerBoolean

Returns whether to display the manual header in plugin help.

Returns:

  • (Boolean)

    whether to display the manual header in plugin help



34
# File 'lib/aspera/cli/main.rb', line 34

MEMBERS = %i[options transfer config formatter persistency man_header].freeze

#optionsManager

Returns the command line options manager.

Returns:

  • (Manager)

    the command line options manager



34
# File 'lib/aspera/cli/main.rb', line 34

MEMBERS = %i[options transfer config formatter persistency man_header].freeze

#persistencyObject

Returns # whatever the type is.

Returns:

  • (Object)

    # whatever the type is



34
# File 'lib/aspera/cli/main.rb', line 34

MEMBERS = %i[options transfer config formatter persistency man_header].freeze

#transferTransferAgent

Returns the transfer agent, used by transfer plugins.

Returns:

  • (TransferAgent)

    the transfer agent, used by transfer plugins



34
# File 'lib/aspera/cli/main.rb', line 34

MEMBERS = %i[options transfer config formatter persistency man_header].freeze

Instance Method Details

#only_manual!Object



54
55
56
# File 'lib/aspera/cli/main.rb', line 54

def only_manual!
  @transfer = :only_manual
end

#only_manual?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/aspera/cli/main.rb', line 50

def only_manual?
  transfer.eql?(:only_manual)
end

#validateObject

Validate that all members are set, raise exception if not



43
44
45
46
47
48
# File 'lib/aspera/cli/main.rb', line 43

def validate
  MEMBERS.each do |i|
    Aspera.assert(instance_variable_defined?(:"@#{i}"))
    Aspera.assert(!instance_variable_get(:"@#{i}").nil?)
  end
end