Class: Vtk::Command
- Inherits:
-
Object
- Object
- Vtk::Command
- Extended by:
- Forwardable
- Defined in:
- lib/vtk/command.rb
Overview
Command class that all command inherit from
Direct Known Subclasses
Vtk::Commands::Module::Add, Vtk::Commands::Module::Controller, Vtk::Commands::Module::Model, Vtk::Commands::Module::Serializer, Vtk::Commands::Module::Service, Vtk::Commands::Socks::Off, Vtk::Commands::Socks::On, Vtk::Commands::Socks::Setup
Instance Method Summary collapse
-
#command(**options) ⇒ Object
The external commands runner.
-
#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.
-
#initialize ⇒ Command
constructor
A new instance of Command.
-
#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.
Constructor Details
#initialize ⇒ Command
Returns a new instance of Command.
13 14 15 16 |
# File 'lib/vtk/command.rb', line 13 def initialize command_name = self.class.to_s.split('::').last(2).join('_').downcase Vtk::Analytics.new(name: command_name).log end |
Instance Method Details
#command(**options) ⇒ Object
The external commands runner
33 34 35 36 |
# File 'lib/vtk/command.rb', line 33 def command(**) require 'tty-command' TTY::Command.new() end |
#cursor ⇒ Object
The cursor movement
43 44 45 46 |
# File 'lib/vtk/command.rb', line 43 def cursor require 'tty-cursor' TTY::Cursor end |
#editor ⇒ Object
Open a file or text in the user’s preferred editor
53 54 55 56 |
# File 'lib/vtk/command.rb', line 53 def editor require 'tty-editor' TTY::Editor end |
#exec_exist?(*args) ⇒ Boolean
Check if executable exists
123 124 125 126 |
# File 'lib/vtk/command.rb', line 123 def exec_exist?(*args) require 'tty-which' TTY::Which.exist?(*args) end |
#execute ⇒ Object
Execute this command
21 22 23 24 25 26 |
# File 'lib/vtk/command.rb', line 21 def execute(*) raise( NotImplementedError, "#{self.class}##{__method__} must be implemented" ) end |
#generator ⇒ Object
File manipulation utility methods
63 64 65 66 |
# File 'lib/vtk/command.rb', line 63 def generator require 'tty-file' TTY::File end |
#pager(**options) ⇒ Object
Terminal output paging
73 74 75 76 |
# File 'lib/vtk/command.rb', line 73 def pager(**) require 'tty-pager' TTY::Pager.new() end |
#platform ⇒ Object
Terminal platform and OS properties
83 84 85 86 |
# File 'lib/vtk/command.rb', line 83 def platform require 'tty-platform' TTY::Platform.new end |
#prompt(**options) ⇒ Object
The interactive prompt
93 94 95 96 |
# File 'lib/vtk/command.rb', line 93 def prompt(**) require 'tty-prompt' TTY::Prompt.new() end |
#screen ⇒ Object
Get terminal screen properties
103 104 105 106 |
# File 'lib/vtk/command.rb', line 103 def screen require 'tty-screen' TTY::Screen end |
#which(*args) ⇒ Object
The unix which utility
113 114 115 116 |
# File 'lib/vtk/command.rb', line 113 def which(*args) require 'tty-which' TTY::Which.which(*args) end |