Class: FIS::Command

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/fis/command.rb

Overview

Inheritable helpers for common command tasks

Instance Method Summary collapse

Instance Method Details

#command(**options) ⇒ Object

The external commands runner



25
26
27
28
# File 'lib/fis/command.rb', line 25

def command(**options)
  require 'tty-command'
  TTY::Command.new(options)
end

#cursorObject

The cursor movement



35
36
37
38
# File 'lib/fis/command.rb', line 35

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

#editorObject

Open a file or text in the user’s preferred editor



45
46
47
48
# File 'lib/fis/command.rb', line 45

def editor
  require 'tty-editor'
  TTY::Editor
end

#exec_exist?(*args) ⇒ Boolean

Check if executable exists

Returns:

  • (Boolean)

See Also:



115
116
117
118
# File 'lib/fis/command.rb', line 115

def exec_exist?(*args)
  require 'tty-which'
  TTY::Which.exist?(*args)
end

#executeObject

Execute this command

Raises:

  • (NotImplementedError)


13
14
15
16
17
18
# File 'lib/fis/command.rb', line 13

def execute(*)
  raise(
    NotImplementedError,
    "#{self.class}##{__method__} must be implemented"
  )
end

#generatorObject

File manipulation utility methods



55
56
57
58
# File 'lib/fis/command.rb', line 55

def generator
  require 'tty-file'
  TTY::File
end

#pager(**options) ⇒ Object

Terminal output paging



65
66
67
68
# File 'lib/fis/command.rb', line 65

def pager(**options)
  require 'tty-pager'
  TTY::Pager.new(options)
end

#platformObject

Terminal platform and OS properties



75
76
77
78
# File 'lib/fis/command.rb', line 75

def platform
  require 'tty-platform'
  TTY::Platform.new
end

#prompt(**options) ⇒ Object

The interactive prompt



85
86
87
88
# File 'lib/fis/command.rb', line 85

def prompt(**options)
  require 'tty-prompt'
  TTY::Prompt.new(options)
end

#screenObject

Get terminal screen properties



95
96
97
98
# File 'lib/fis/command.rb', line 95

def screen
  require 'tty-screen'
  TTY::Screen
end

#which(*args) ⇒ Object

The unix which utility



105
106
107
108
# File 'lib/fis/command.rb', line 105

def which(*args)
  require 'tty-which'
  TTY::Which.which(*args)
end