Class: Yapo::Command

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

Instance Method Summary collapse

Instance Method Details

#command(**options) ⇒ Object

The external commands runner



23
24
25
26
# File 'lib/yapo/command.rb', line 23

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

#exec_exist?(*args) ⇒ Boolean

Check if executable exists

Returns:

  • (Boolean)


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

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

#executeObject

Execute this command

Raises:

  • (NotImplementedError)


15
16
17
18
19
20
# File 'lib/yapo/command.rb', line 15

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

#generatorObject

File manipulation utility methods



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

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

#pastel(**options) ⇒ Object

The output styler



29
30
31
32
# File 'lib/yapo/command.rb', line 29

def pastel(**options)
  require 'pastel'
  Pastel.new(options)
end

#platformObject

Terminal platform and OS properties



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

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

#prompt(**options) ⇒ Object

The interactive prompt



47
48
49
50
# File 'lib/yapo/command.rb', line 47

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

#screenObject

Get terminal screen properties



53
54
55
56
# File 'lib/yapo/command.rb', line 53

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

#which(*args) ⇒ Object

The unix which utility



59
60
61
62
# File 'lib/yapo/command.rb', line 59

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