Class: Wavesync::Commands::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/wavesync/commands/command.rb

Direct Known Subclasses

Analyze, Help, Set, Sync

Class Attribute Summary collapse

Instance Method Summary collapse

Class Attribute Details

.descriptionObject

Returns the value of attribute description.



9
10
11
# File 'lib/wavesync/commands/command.rb', line 9

def description
  @description
end

.nameObject

Returns the value of attribute name.



9
10
11
# File 'lib/wavesync/commands/command.rb', line 9

def name
  @name
end

.optionsObject



12
# File 'lib/wavesync/commands/command.rb', line 12

def options = @options || []

.subcommandsObject



13
# File 'lib/wavesync/commands/command.rb', line 13

def subcommands = @subcommands || []

Instance Method Details

#parse_options(banner:) ⇒ Object

: (banner: String) ?{ (OptionParser, Hash[Symbol, untyped]) -> void } -> [Hash[Symbol, untyped], Config]



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/wavesync/commands/command.rb', line 17

def parse_options(banner:)
  options = {} #: Hash[Symbol, untyped]
  OptionParser.new do |opts|
    opts.banner = banner
    opts.on(*CONFIG_OPTION.to_a) { |value| options[:config] = value }
    yield opts, options if block_given?
  end.parse!
  config_path = options[:config] || Wavesync::Config::DEFAULT_PATH
  config = Commands.load_config(config_path)
  [options, config]
end