Module: Watson

Included in:
Command, Config, FS, Formatters::BaseFormatter, Parser, Printer, Remote, Remote::Asana, Remote::Bitbucket, Remote::GitHub, Remote::GitLab
Defined in:
lib/watson.rb,
lib/watson/fs.rb,
lib/watson/asana.rb,
lib/watson/config.rb,
lib/watson/github.rb,
lib/watson/gitlab.rb,
lib/watson/parser.rb,
lib/watson/remote.rb,
lib/watson/command.rb,
lib/watson/printer.rb,
lib/watson/version.rb,
lib/watson/bitbucket.rb

Defined Under Namespace

Modules: Formatters Classes: Command, Config, FS, Parser, Printer, Remote

Constant Summary collapse

BOLD =

Color definitions for pretty printing Defined here because we need Global scope but makes sense to have them in the printer.rb file at least

"\e[01m"
UNDERLINE =
"\e[4m"
RESET =
"\e[00m"
GRAY =
"\e[38;5;0m"
RED =
"\e[38;5;1m"
GREEN =
"\e[38;5;2m"
YELLOW =
"\e[38;5;3m"
BLUE =
"\e[38;5;4m"
MAGENTA =
"\e[38;5;5m"
CYAN =
"\e[38;5;6m"
WHITE =
"\e[38;5;7m"
VERSION =
"1.6.3"
@@debug_mode =
Array.new()

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.debug_modeObject

Returns the value of attribute debug_mode.



36
37
38
# File 'lib/watson.rb', line 36

def debug_mode
  @debug_mode
end

Class Method Details

.check_lessObject

Perform system check to see if we are able to use unix less for printing



74
75
76
77
78
# File 'lib/watson.rb', line 74

def check_less
  # Check if system has less (so we can print out to it to allow scrolling)
  # [todo] - Implement this scrolling thing inside watson with ncurses
  return system("which less > /dev/null 2>&1")
end

.debug_print(msg) ⇒ Object

Global debug print that prints based on local file DEBUG flag as well as GLOBAL debug flag



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/watson.rb', line 50

def debug_print(msg)

  # If nothing set from CLI, debug_mode will be nil
  return if Watson.debug_mode.nil?

  # If empty, just --debug passed, print ALL, else selective print
  _enabled = false
  if !Watson.debug_mode.empty?
    _debug = (self.is_a? Class) ? self.name.downcase : self.class.name.downcase
    Watson.debug_mode.each do |dbg|
      _enabled = true if _debug.include?(dbg)
    end
  else
    _enabled = true
  end

  return if !_enabled
  (msg.is_a? Hash) ? (pp msg) : (print "=> #{msg}")

end