Class: SocialSnippet::CommandLine::SSpm::MainCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/social_snippet/command_line/sspm/main_command.rb

Instance Attribute Summary collapse

Attributes inherited from Command

#args, #input_stream, #opt_parser, #options, #output_stream, #streams, #tokens

Instance Method Summary collapse

Methods inherited from Command

#define_option, #init, #social_snippet

Constructor Details

#initialize(new_args, new_streams = {}) ⇒ MainCommand

Returns a new instance of MainCommand


7
8
9
10
# File 'lib/social_snippet/command_line/sspm/main_command.rb', line 7

def initialize(new_args, new_streams = {})
  super
  @sub_commands = SSpm::SubCommands.all
end

Instance Attribute Details

#sub_commandsObject (readonly)

Returns the value of attribute sub_commands


5
6
7
# File 'lib/social_snippet/command_line/sspm/main_command.rb', line 5

def sub_commands
  @sub_commands
end

Instance Method Details

#define_optionsObject


12
13
# File 'lib/social_snippet/command_line/sspm/main_command.rb', line 12

def define_options
end

#runObject


24
25
26
27
28
29
30
31
# File 'lib/social_snippet/command_line/sspm/main_command.rb', line 24

def run
  if has_subcommand?
    command_name = args.shift
    find_subcommand command_name
  else
    help
  end
end

#usageObject


15
16
17
18
19
20
21
22
# File 'lib/social_snippet/command_line/sspm/main_command.rb', line 15

def usage
  <<EOF
Usage: sspm <command> [options] [--]

Commands:
#{usage_subcommands}
EOF
end