Class: Memo::Cli

Inherits:
Object
  • Object
show all
Defined in:
lib/memo/cli/cli.rb,
lib/memo/cli/error/error.rb,
lib/memo/cli/command/edit.rb,
lib/memo/cli/command/help.rb,
lib/memo/cli/command/list.rb,
lib/memo/cli/command/fuzzy.rb,
lib/memo/cli/command/setup.rb,
lib/memo/cli/command/today.rb,
lib/memo/cli/command/config.rb,
lib/memo/cli/command/custom.rb,
lib/memo/cli/command/preview.rb

Defined Under Namespace

Modules: Command, Error

Instance Method Summary collapse

Constructor Details

#initialize(input, os: Memo::OS.new) ⇒ Cli

Returns a new instance of Cli.



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

def initialize(
  input,
  os: Memo::OS.new
)
  @command = input[0]
  @options = Option.new input[1..]
  @os = os
end

Instance Method Details

#callObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/memo/cli/cli.rb', line 12

def call
  cmd = case @command
        when "edit", "e", nil
          Command::Edit
        when "preview", "p"
          Command::Preview
        when "today", "t"
          Command::Today
        when "list", "l"
          Command::List
        when "config", "c"
          Command::Config
        when "help", "h"
          Command::Help
        when "setup", "s"
          Command::Setup
        when "fuzzy", "f"
          Command::Fuzzy
        else
          @options = @command
          Command::Custom
        end

  cmd.new(@options, os: @os).()
end