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

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(**options)
  require 'tty-command'
  TTY::Command.new(options)
end

#configObject

Commandlet Configuration



10
11
12
# File 'lib/k_starter/tty_helpers.rb', line 10

def config
  KStarter::App.config
end

#cursorObject

The cursor movement



29
30
31
32
# File 'lib/k_starter/tty_helpers.rb', line 29

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

#editorObject

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

Returns:

  • (Boolean)

See Also:



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

#generatorObject

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(**options)
  require 'tty-pager'
  TTY::Pager.new(options)
end

#platformObject

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

#promptObject

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

#screenObject

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