Class: Moneylovercli::Command

Inherits:
Object
  • Object
show all
Extended by:
Forwardable, T::Sig
Defined in:
lib/moneylovercli/command.rb

Instance Method Summary collapse

Instance Method Details

#command(**options) ⇒ Object

The external commands runner



30
31
32
33
# File 'lib/moneylovercli/command.rb', line 30

def command(**options)
  require 'tty-command'
  TTY::Command.new(options)
end

#configObject



125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/moneylovercli/command.rb', line 125

def config
  require 'tty-config'
  require 'tty-file'
  config_dir = "#{Dir.home}/.config/moneylovercli"
  TTY::File.create_dir(config_dir)

  @config ||= begin
    config = TTY::Config.new
    config.filename = 'config'
    config.extname = '.yml'
    # config.append_path(Dir.pwd)
    config.append_path(config_dir)
    config
  end
end

#cursorObject

The cursor movement



40
41
42
43
# File 'lib/moneylovercli/command.rb', line 40

def cursor
  require 'tty-cursor'
  TTY::Cursor
end

#editorObject

Open a file or text in the user’s preferred editor



50
51
52
53
# File 'lib/moneylovercli/command.rb', line 50

def editor
  require 'tty-editor'
  TTY::Editor
end

#exec_exist?(*args) ⇒ Boolean

Check if executable exists

Returns:

  • (Boolean)

See Also:



120
121
122
123
# File 'lib/moneylovercli/command.rb', line 120

def exec_exist?(*args)
  require 'tty-which'
  TTY::Which.exist?(*args)
end

#executeObject

Execute this command

Raises:

  • (NotImplementedError)


18
19
20
21
22
23
# File 'lib/moneylovercli/command.rb', line 18

def execute(*)
  raise(
    NotImplementedError,
    "#{self.class}##{__method__} must be implemented"
  )
end

#generatorObject

File manipulation utility methods



60
61
62
63
# File 'lib/moneylovercli/command.rb', line 60

def generator
  require 'tty-file'
  TTY::File
end

#pager(**options) ⇒ Object

Terminal output paging



70
71
72
73
# File 'lib/moneylovercli/command.rb', line 70

def pager(**options)
  require 'tty-pager'
  TTY::Pager.new(options)
end

#platformObject

Terminal platform and OS properties



80
81
82
83
# File 'lib/moneylovercli/command.rb', line 80

def platform
  require 'tty-platform'
  TTY::Platform.new
end

#prompt(**options) ⇒ Object

The interactive prompt



90
91
92
93
# File 'lib/moneylovercli/command.rb', line 90

def prompt(**options)
  require 'tty-prompt'
  TTY::Prompt.new(options)
end

#screenObject

Get terminal screen properties



100
101
102
103
# File 'lib/moneylovercli/command.rb', line 100

def screen
  require 'tty-screen'
  TTY::Screen
end

#which(*args) ⇒ Object

The unix which utility



110
111
112
113
# File 'lib/moneylovercli/command.rb', line 110

def which(*args)
  require 'tty-which'
  TTY::Which.which(*args)
end