Module: KStarter::TtyHelpers
- Included in:
- Commands::Command, Questions::BaseQuestion, Starters::Base
- Defined in:
- lib/k_starter/tty_helpers.rb
Overview
Base command class
Instance Method Summary collapse
-
#command(**options) ⇒ Object
The external commands runner.
-
#config ⇒ Object
Commandlet Configuration.
-
#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.
-
#generator ⇒ Object
File manipulation utility methods.
-
#pager(**options) ⇒ Object
Terminal output paging.
-
#platform ⇒ Object
Terminal platform and OS properties.
-
#prompt ⇒ 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
19 20 21 22 |
# File 'lib/k_starter/tty_helpers.rb', line 19 def command(**) require 'tty-command' TTY::Command.new() end |
#config ⇒ Object
Commandlet Configuration
10 11 12 |
# File 'lib/k_starter/tty_helpers.rb', line 10 def config KStarter::App.config end |
#cursor ⇒ Object
The cursor movement
29 30 31 32 |
# File 'lib/k_starter/tty_helpers.rb', line 29 def cursor require 'tty-cursor' TTY::Cursor end |
#editor ⇒ Object
Open a file or text in the user’s preferred editor
39 40 41 42 |
# File 'lib/k_starter/tty_helpers.rb', line 39 def editor require 'tty-editor' TTY::Editor end |
#exec_exist?(*args) ⇒ Boolean
Check if executable exists
113 114 115 116 |
# File 'lib/k_starter/tty_helpers.rb', line 113 def exec_exist?(*args) require 'tty-which' TTY::Which.exist?(*args) end |
#generator ⇒ Object
File manipulation utility methods
49 50 51 52 |
# File 'lib/k_starter/tty_helpers.rb', line 49 def generator require 'tty-file' TTY::File end |
#pager(**options) ⇒ Object
Terminal output paging
59 60 61 62 |
# File 'lib/k_starter/tty_helpers.rb', line 59 def pager(**) require 'tty-pager' TTY::Pager.new() end |
#platform ⇒ Object
Terminal platform and OS properties
69 70 71 72 |
# File 'lib/k_starter/tty_helpers.rb', line 69 def platform require 'tty-platform' TTY::Platform.new end |
#prompt ⇒ Object
The interactive prompt
79 80 81 82 83 84 85 86 |
# File 'lib/k_starter/tty_helpers.rb', line 79 def prompt require 'tty-prompt' p = TTY::Prompt.new p.on(:keyescape) do raise KStarter::EscapePressed end p end |
#screen ⇒ Object
Get terminal screen properties
93 94 95 96 |
# File 'lib/k_starter/tty_helpers.rb', line 93 def screen require 'tty-screen' TTY::Screen end |
#which(*args) ⇒ Object
The unix which utility
103 104 105 106 |
# File 'lib/k_starter/tty_helpers.rb', line 103 def which(*args) require 'tty-which' TTY::Which.which(*args) end |