Class: TTY::Cmd
- Inherits:
-
Object
- Object
- TTY::Cmd
- Extended by:
- Forwardable
- Includes:
- PathHelpers
- Defined in:
- lib/tty/cmd.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#command(**options) ⇒ Object
The external commands runner.
- #constantinize(str) ⇒ 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.
Methods included from PathHelpers
#name_from_path, #relative_path_from, #root_path, #within_root_path
Instance Method Details
#command(**options) ⇒ Object
The external commands runner
32 33 34 35 |
# File 'lib/tty/cmd.rb', line 32 def command(**) require 'tty-command' TTY::Command.new() end |
#constantinize(str) ⇒ Object
127 128 129 130 |
# File 'lib/tty/cmd.rb', line 127 def constantinize(str) str.gsub(/-[_-]*(?![_-]|$)/) { "::" } .gsub(/([_-]+|(::)|^)(.|$)/) { $2.to_s + $3.upcase} end |
#cursor ⇒ Object
The cursor movement
42 43 44 45 |
# File 'lib/tty/cmd.rb', line 42 def cursor require 'tty-cursor' TTY::Cursor end |
#editor ⇒ Object
Open a file or text in the user’s preferred editor
52 53 54 55 |
# File 'lib/tty/cmd.rb', line 52 def editor require 'tty-editor' TTY::Editor end |
#exec_exist?(*args) ⇒ Boolean
Check if executable exists
122 123 124 125 |
# File 'lib/tty/cmd.rb', line 122 def exec_exist?(*args) require 'tty-which' TTY::Which.exist?(*args) end |
#execute ⇒ Object
Execute this command
20 21 22 23 24 25 |
# File 'lib/tty/cmd.rb', line 20 def execute(*) raise( NotImplementedError, "#{self.class}##{__method__} must be implemented" ) end |
#generator ⇒ Object
File manipulation utility methods
62 63 64 65 |
# File 'lib/tty/cmd.rb', line 62 def generator require 'tty-file' TTY::File end |
#pager(**options) ⇒ Object
Terminal output paging
72 73 74 75 |
# File 'lib/tty/cmd.rb', line 72 def pager(**) require 'tty-pager' TTY::Pager.new() end |
#platform ⇒ Object
Terminal platform and OS properties
82 83 84 85 |
# File 'lib/tty/cmd.rb', line 82 def platform require 'tty-platform' TTY::Platform.new end |
#prompt(**options) ⇒ Object
The interactive prompt
92 93 94 95 |
# File 'lib/tty/cmd.rb', line 92 def prompt(**) require 'tty-prompt' TTY::Prompt.new() end |
#screen ⇒ Object
Get terminal screen properties
102 103 104 105 |
# File 'lib/tty/cmd.rb', line 102 def screen require 'tty-screen' TTY::Screen end |
#which(*args) ⇒ Object
The unix which utility
112 113 114 115 |
# File 'lib/tty/cmd.rb', line 112 def which(*args) require 'tty-which' TTY::Which.which(*args) end |