Sha256: 864014cbf0cd1574adc4d23dee6d85477854a30806669a74bff6e427cd151172
Contents?: true
Size: 987 Bytes
Versions: 31
Compression:
Stored size: 987 Bytes
Contents
# frozen_string_literal: true require "optparse" module RubyNext module Commands class Base class << self def run(args) new(args).run end end attr_reader :dry_run alias dry_run? dry_run def initialize(args) parse! args end def parse!(*) raise NotImplementedError end def run raise NotImplementedError end def log(msg) return unless CLI.verbose? if CLI.dry_run? $stdout.puts "[DRY RUN] #{msg}" else $stdout.puts msg end end def base_parser OptionParser.new do |opts| yield opts opts.on("-V", "Turn on verbose mode") do CLI.verbose = true end opts.on("--dry-run", "Print verbose output without generating files") do CLI.dry_run = true CLI.verbose = true end end end end end end
Version data entries
31 entries across 31 versions & 1 rubygems