Class: Markdo::CLI

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

Instance Method Summary collapse

Constructor Details

#initialize(command_support = CommandSupport.new) ⇒ CLI

Returns a new instance of CLI.



5
6
7
8
9
10
# File 'lib/markdo/cli.rb', line 5

def initialize(command_support = CommandSupport.new)
  @stdin = command_support.stdin
  @stdout = command_support.stdout
  @stderr = command_support.stderr
  @full_env = command_support.env
end

Instance Method Details

#run(command_name = 'help', *args) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/markdo/cli.rb', line 12

def run(command_name = 'help', *args)
  command = case command_name
            when 'q'
              QueryCommand
            when 'starred'
              StarCommand
            when '--version'
              VersionCommand
            else
              choose_command_class(command_name)
            end

  command_support = CommandSupport.new(stdin: @stdin,
                                       stdout: @stdout,
                                       stderr: @stderr,
                                       env: merged_env)
  command.new(command_support).run(*args)
end