Class: Moneylovercli::Command
- Inherits:
-
Object
- Object
- Moneylovercli::Command
- Extended by:
- Forwardable, T::Sig
- Defined in:
- lib/moneylovercli/command.rb
Direct Known Subclasses
Moneylovercli::Commands::AddTransaction, Moneylovercli::Commands::Login, Moneylovercli::Commands::Wallets
Instance Method Summary collapse
-
#command(**options) ⇒ Object
The external commands runner.
- #config ⇒ Object
-
#cursor ⇒ Object
The cursor movement.
-
#editor ⇒ Object
Open a file or text in the user’s preferred editor.
-
#exec_exist?(*args) ⇒ Boolean
Check if executable exists.
-
#execute ⇒ Object
Execute this command.
-
#generator ⇒ Object
File manipulation utility methods.
-
#pager(**options) ⇒ Object
Terminal output paging.
-
#platform ⇒ Object
Terminal platform and OS properties.
-
#prompt(**options) ⇒ Object
The interactive prompt.
-
#screen ⇒ Object
Get terminal screen properties.
-
#which(*args) ⇒ Object
The unix which utility.
Instance Method Details
#command(**options) ⇒ Object
The external commands runner
30 31 32 33 |
# File 'lib/moneylovercli/command.rb', line 30 def command(**) require 'tty-command' TTY::Command.new() end |
#config ⇒ Object
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 |
#cursor ⇒ Object
The cursor movement
40 41 42 43 |
# File 'lib/moneylovercli/command.rb', line 40 def cursor require 'tty-cursor' TTY::Cursor end |
#editor ⇒ Object
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
120 121 122 123 |
# File 'lib/moneylovercli/command.rb', line 120 def exec_exist?(*args) require 'tty-which' TTY::Which.exist?(*args) end |
#execute ⇒ Object
Execute this command
18 19 20 21 22 23 |
# File 'lib/moneylovercli/command.rb', line 18 def execute(*) raise( NotImplementedError, "#{self.class}##{__method__} must be implemented" ) end |
#generator ⇒ Object
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(**) require 'tty-pager' TTY::Pager.new() end |
#platform ⇒ Object
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(**) require 'tty-prompt' TTY::Prompt.new() end |
#screen ⇒ Object
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 |