Class: Sprout::CommandLine

Inherits:
Executable::Base show all
Defined in:
lib/sprout/command_line.rb

Constant Summary

Constant Summary

Constants included from Executable

Executable::DEFAULT_FILE_EXPRESSION, Executable::DEFAULT_PREFIX, Executable::DEFAULT_SHORT_PREFIX

Instance Attribute Summary (collapse)

Attributes inherited from Executable::Base

#abort_on_failure, #default_prefix, #default_short_prefix, #executable, #param_hash, #params, #pkg_name, #pkg_version, #prerequisites, #rake_task_name

Instance Method Summary (collapse)

Methods inherited from Executable::Base

add_param, add_param_alias, #binary_path, #binary_path=, #create_outer_task, #default_file_expression, #execute_delegate, #from_hash, #initialize_defaults, #library_added, #parse_extra_options!, #parse_rake_task_arg, #prepare, set, static_default_value_collection, static_parameter_collection, #stderr, #stderr=, #stdout, #stdout=, #system_execute, #to_hash, #to_help, #to_rake, #to_shell, #update_rake_task_name_from_args

Methods included from Concern

#append_features, extended, #included

Constructor Details

- (CommandLine) initialize

A new instance of CommandLine



15
16
17
18
# File 'lib/sprout/command_line.rb', line 15

def initialize
  super
  @logger = $stdout
end

Instance Attribute Details

- (IO) logger

Default $stdout, Replace value in test context.

Returns:

  • (IO)

    default $stdout, Replace value in test context.



13
14
15
# File 'lib/sprout/command_line.rb', line 13

def logger
  @logger
end

- (Object) version

Get the version of the Sprout gem



7
# File 'lib/sprout/command_line.rb', line 7

add_param :version, Boolean, :default => false, :hidden_value => true

Instance Method Details

- (Object) execute



27
28
29
30
31
# File 'lib/sprout/command_line.rb', line 27

def execute
  if version
    logger.puts "sprout #{Sprout::VERSION::STRING}"
  end
end

- (Object) parse!(options)



20
21
22
23
24
25
# File 'lib/sprout/command_line.rb', line 20

def parse! options
  if options.empty?
    handle_parse_error Sprout::Errors::UsageError.new("At least one parameter is required.")
  end
  super
end