class Devbin::Command

Public Instance Methods

command(**options) click to toggle source

The external commands runner

@see www.rubydoc.info/gems/tty-command

@api public

# File lib/devbin/command.rb, line 26
def command(**options)
  require "tty-command"
  TTY::Command.new(options)
end
cursor() click to toggle source

The cursor movement

@see www.rubydoc.info/gems/tty-cursor

@api public

# File lib/devbin/command.rb, line 36
def cursor
  require "tty-cursor"
  TTY::Cursor
end
docker_pwd() click to toggle source
# File lib/devbin/command.rb, line 155
def docker_pwd
  @docker_pwd ||=
    begin
      path = find_pwd("docker")
      if path.empty?
        fail "Cannot find the `docker' folder"
      end
      path.push("docker").join("/")
    end
end
docker_sync_pwd() click to toggle source
# File lib/devbin/command.rb, line 144
def docker_sync_pwd
  @docker_sync_pwd ||=
    begin
      path = find_pwd("docker-sync.yml")
      if path.empty?
        fail "Cannot find the `docker-sync.yml' file"
      end
      path.join("/")
    end
end
editor() click to toggle source

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

@see www.rubydoc.info/gems/tty-editor

@api public

# File lib/devbin/command.rb, line 46
def editor
  require "tty-editor"
  TTY::Editor
end
exec_exist?(*args) click to toggle source

Check if executable exists

@see www.rubydoc.info/gems/tty-which

@api public

# File lib/devbin/command.rb, line 116
def exec_exist?(*args)
  require "tty-which"
  TTY::Which.exist?(*args)
end
execute(*) click to toggle source

Execute this command

@api public

# File lib/devbin/command.rb, line 14
def execute(*)
  raise(
    NotImplementedError,
    "#{self.class}##{__method__} must be implemented"
  )
end
find_pwd(file_or_directory_name) click to toggle source
# File lib/devbin/command.rb, line 129
def find_pwd(file_or_directory_name)
  path = [".", file_or_directory_name]
  file = nil
  results = Dir[path.join("/")]
  file = results[0]
  return path[0..-2] unless results.empty?
  3.times do
    path.unshift("..")
    results = Dir[path.join("/")]
    file = results[0]
    return path[0..-2] unless results.empty?
  end
  []
end
generator() click to toggle source

File manipulation utility methods

@see www.rubydoc.info/gems/tty-file

@api public

# File lib/devbin/command.rb, line 56
def generator
  require "tty-file"
  TTY::File
end
pager(**options) click to toggle source

Terminal output paging

@see www.rubydoc.info/gems/tty-pager

@api public

# File lib/devbin/command.rb, line 66
def pager(**options)
  require "tty-pager"
  TTY::Pager.new(options)
end
pastel() click to toggle source
# File lib/devbin/command.rb, line 121
def pastel
  @pastel ||=
    begin
      require "pastel"
      Pastel.new
    end
end
platform() click to toggle source

Terminal platform and OS properties

@see www.rubydoc.info/gems/tty-pager

@api public

# File lib/devbin/command.rb, line 76
def platform
  require "tty-platform"
  TTY::Platform.new
end
prompt(**options) click to toggle source

The interactive prompt

@see www.rubydoc.info/gems/tty-prompt

@api public

# File lib/devbin/command.rb, line 86
def prompt(**options)
  require "tty-prompt"
  TTY::Prompt.new(options)
end
screen() click to toggle source

Get terminal screen properties

@see www.rubydoc.info/gems/tty-screen

@api public

# File lib/devbin/command.rb, line 96
def screen
  require "tty-screen"
  TTY::Screen
end
which(*args) click to toggle source

The unix which utility

@see www.rubydoc.info/gems/tty-which

@api public

# File lib/devbin/command.rb, line 106
def which(*args)
  require "tty-which"
  TTY::Which.which(*args)
end