Class: S3sec::Command

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

Instance Method Summary collapse

Instance Method Details

#command(**options) ⇒ Object

The external commands runner



27
28
29
30
# File 'lib/s3sec/command.rb', line 27

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

#configObject

Read configuration



138
139
140
141
142
143
144
145
146
# File 'lib/s3sec/command.rb', line 138

def config
  return @config if @config
  @config = TTY::Config.new
  @config.filename = 'config'
  @config.extname = '.yml'
  @config.append_path Dir.pwd
  @config.read if @config.exist?
  @config
end

#cursorObject

The cursor movement



37
38
39
40
# File 'lib/s3sec/command.rb', line 37

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

#editorObject

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



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

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

#exec_exist?(*args) ⇒ Boolean

Check if executable exists

Returns:

  • (Boolean)

See Also:



128
129
130
131
# File 'lib/s3sec/command.rb', line 128

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/s3sec/command.rb', line 15

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

#generatorObject

File manipulation utility methods



57
58
59
60
# File 'lib/s3sec/command.rb', line 57

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

#pager(**options) ⇒ Object

Terminal output paging



67
68
69
70
# File 'lib/s3sec/command.rb', line 67

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

#pastel(**options) ⇒ Object

The interactive pastel



87
88
89
90
# File 'lib/s3sec/command.rb', line 87

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

#platformObject

Terminal platform and OS properties



77
78
79
80
# File 'lib/s3sec/command.rb', line 77

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

#prompt(**options) ⇒ Object

The interactive prompt



98
99
100
101
# File 'lib/s3sec/command.rb', line 98

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

#screenObject

Get terminal screen properties



108
109
110
111
# File 'lib/s3sec/command.rb', line 108

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

#which(*args) ⇒ Object

The unix which utility



118
119
120
121
# File 'lib/s3sec/command.rb', line 118

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