Class: MrHyde::Toolii

Inherits:
Object
  • Object
show all
Extended by:
GLI::App
Defined in:
lib/mrhyde/cli/main.rb

Overview

NOTE: gli added function are class methods (thus, wrap class Toolii in Tool for now)

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.fetch_script(name) ⇒ Object



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

def self.fetch_script( name )

  ## first try local version in working folder

  text = ''
  local_script = "./#{name}.rb"
  if File.exist?( local_script )
    text = File.read_utf8( local_script )
  else  ## fetch remote script
    url = "https://github.com/mrhydescripts/scripts/raw/master/#{name}.rb"

    puts "GET #{url}"    ##  todo - add color e.g. .bold.green
    
    ## assume utf8 text encoding for now
    worker = Fetcher::Worker.new
    text = worker.read_utf8!( url )
  end

  text
end

.loggerObject



25
# File 'lib/mrhyde/cli/main.rb', line 25

def self.logger()       @@logger; end

.logger=(value) ⇒ Object



24
# File 'lib/mrhyde/cli/main.rb', line 24

def self.logger=(value) @@logger=value; end

.optsObject



29
# File 'lib/mrhyde/cli/main.rb', line 29

def self.opts()        @@opts; end

.opts=(value) ⇒ Object

todo: find a better name e.g. change to settings? config? safe_opts? why? why not?



28
# File 'lib/mrhyde/cli/main.rb', line 28

def self.opts=(value)  @@opts = value; end

Instance Method Details

#verboseObject

todo: use -w for short form? check ruby interpreter if in use too?



44
# File 'lib/mrhyde/cli/main.rb', line 44

switch [:verbose], negatable: false