Class: Sprout::CommandLine

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

Constant Summary

Constants included from Executable

DEFAULT_FILE_EXPRESSION, DEFAULT_PREFIX, DEFAULT_SHORT_PREFIX

Instance Attribute Summary (collapse)

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, #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 'sprout/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 'sprout/lib/sprout/command_line.rb', line 13

def logger
  @logger
end

- (Boolean) version

Get the version of the Sprout gem

Returns:

  • (Boolean)

    An instance of Boolean



# File ''

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

Instance Method Details

- (Object) execute



27
28
29
30
31
# File 'sprout/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 'sprout/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