Sha256: f0d0e83344df5009da3652bdaa17de81c41813a3c8d4ab4fea9ba291e9baac20
Contents?: true
Size: 981 Bytes
Versions: 6
Compression:
Stored size: 981 Bytes
Contents
require "magellan/cli" require 'thor' module Magellan module Cli class Base < Thor class_option :verbose, type: :boolean, aliases: "-V" class_option :dryrun , type: :boolean, aliases: "-D" no_commands do def sub(klass) task = klass.new task.options = self.options task end def opts @opts ||= options || {} end def dryrun? opts[:dryrun] end def verbose? opts[:verbose] end def verbose(msg) $stderr.puts("\e[34m#{msg}\e[0m") if verbose? end def info(msg) $stderr.puts(msg) end def success(msg) $stderr.puts("\e[32m#{msg}\e[0m") end def error(msg) $stderr.puts("\e[31m#{msg}\e[0m") end def fatal(msg) verbose(caller.join("\n ")) raise Cli::Error, msg end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems