Sha256: de062d6ce5dc1f5f122ec22fc10922c4d049f0d5af10e3fd6df49a3433cdb5d9
Contents?: true
Size: 1.91 KB
Versions: 6
Compression:
Stored size: 1.91 KB
Contents
# frozen_string_literal: true require "version" require "tools" require "thor" module Icarus module Mod module CLI # Base class for all subcommands class SubCommandBase < Thor class_option :verbose, aliases: "-v", type: :boolean, repeatable: true, default: [true], desc: "Increase verbosity. May be repeated for even more verbosity." no_commands do def check_false options[:verbose] = [] if options[:verbose].include?(false) end def verbose check_false options[:verbose]&.count || 0 end def verbose? check_false options[:verbose]&.count&.positive? end end def self.banner(command, _namespace = nil, _subcommand = false) # rubocop:disable Style/OptionalBooleanParameter "#{basename} #{subcommand_prefix} #{command.usage}" end def self.subcommand_prefix name.gsub(/.*::/, "").gsub(/^[A-Z]/) { |match| match[0].downcase }.gsub(/[A-Z]/) { |match| "-#{match[0].downcase}" } end end # Require subcommands after the SubCommandBase class is defined require "cli/sync" require "cli/list" require "cli/add" # The main CLI for Icarus Mod Tools class Base < Thor def self.exit_on_failure? true end map %w[--version -V] => :__print_version desc "--version, -V", "print the version and exit" def __print_version puts "IcarusModTool (imt) v#{Icarus::Mod::VERSION}" end desc "sync", "Syncs the databases" subcommand "sync", Sync desc "list", "Lists the databases" subcommand "list", List desc "add", "Adds entries to the databases" subcommand "add", Add end end end end
Version data entries
6 entries across 6 versions & 1 rubygems