Class: Churned::Command

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

Instance Method Summary collapse

Instance Method Details

#command(**options) ⇒ Object

The external commands runner



31
32
33
34
# File 'lib/churned/command.rb', line 31

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

#cursorObject

The cursor movement



41
42
43
44
# File 'lib/churned/command.rb', line 41

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

#dbObject



21
22
23
24
# File 'lib/churned/command.rb', line 21

def db
  require_relative 'commands/db'
  Commands::DB
end

#editorObject

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



51
52
53
54
# File 'lib/churned/command.rb', line 51

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

#exec_exist?(*args) ⇒ Boolean

Check if executable exists

Returns:

  • (Boolean)

See Also:



121
122
123
124
# File 'lib/churned/command.rb', line 121

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

#executeObject

Execute this command

Raises:

  • (NotImplementedError)


14
15
16
17
18
19
# File 'lib/churned/command.rb', line 14

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

#generatorObject

File manipulation utility methods



61
62
63
64
# File 'lib/churned/command.rb', line 61

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

#pager(**options) ⇒ Object

Terminal output paging



71
72
73
74
# File 'lib/churned/command.rb', line 71

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

#platformObject

Terminal platform and OS properties



81
82
83
84
# File 'lib/churned/command.rb', line 81

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

#prompt(**options) ⇒ Object

The interactive prompt



91
92
93
94
# File 'lib/churned/command.rb', line 91

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

#screenObject

Get terminal screen properties



101
102
103
104
# File 'lib/churned/command.rb', line 101

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

#which(*args) ⇒ Object

The unix which utility



111
112
113
114
# File 'lib/churned/command.rb', line 111

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