Rename Base and InternalUseBase.
This commit is contained in:
parent
811f4c5f23
commit
acc7309ca3
@ -3,7 +3,7 @@ require "shellwords"
|
||||
|
||||
require "extend/optparse"
|
||||
|
||||
require "hbc/cli/base"
|
||||
require "hbc/cli/abstract_command"
|
||||
require "hbc/cli/audit"
|
||||
require "hbc/cli/cat"
|
||||
require "hbc/cli/cleanup"
|
||||
@ -23,7 +23,7 @@ require "hbc/cli/uninstall"
|
||||
require "hbc/cli/--version"
|
||||
require "hbc/cli/zap"
|
||||
|
||||
require "hbc/cli/internal_use_base"
|
||||
require "hbc/cli/abstract_internal_command"
|
||||
require "hbc/cli/internal_audit_modified_casks"
|
||||
require "hbc/cli/internal_appcast_checkpoint"
|
||||
require "hbc/cli/internal_checkurl"
|
||||
@ -90,7 +90,8 @@ module Hbc
|
||||
|
||||
def self.command_classes
|
||||
@command_classes ||= constants.map(&method(:const_get))
|
||||
.select { |sym| sym.respond_to?(:run) }
|
||||
.select { |klass| klass.respond_to?(:run) }
|
||||
.reject(&:abstract?)
|
||||
.sort_by(&:command_name)
|
||||
end
|
||||
|
||||
@ -105,7 +106,7 @@ module Hbc
|
||||
end
|
||||
|
||||
def self.should_init?(command)
|
||||
(command.is_a? Class) && (command < CLI::Base) && command.needs_init?
|
||||
command.is_a?(Class) && !command.abstract? && command.needs_init?
|
||||
end
|
||||
|
||||
def self.run_command(command, *rest)
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
module Hbc
|
||||
class CLI
|
||||
class Version < Base
|
||||
class Version < AbstractCommand
|
||||
def self.command_name
|
||||
"--#{super}"
|
||||
end
|
||||
|
||||
@ -1,10 +1,14 @@
|
||||
module Hbc
|
||||
class CLI
|
||||
class Base
|
||||
class AbstractCommand
|
||||
def self.command_name
|
||||
@command_name ||= name.sub(/^.*:/, "").gsub(/(.)([A-Z])/, '\1_\2').downcase
|
||||
end
|
||||
|
||||
def self.abstract?
|
||||
!(name.split("::").last !~ /^Abstract[^a-z]/)
|
||||
end
|
||||
|
||||
def self.visible
|
||||
true
|
||||
end
|
||||
@ -21,6 +25,10 @@ module Hbc
|
||||
false
|
||||
end
|
||||
|
||||
def self.run(*args)
|
||||
new(*args).run
|
||||
end
|
||||
|
||||
def initialize(*args)
|
||||
@args = args
|
||||
end
|
||||
@ -1,6 +1,6 @@
|
||||
module Hbc
|
||||
class CLI
|
||||
class InternalUseBase < Base
|
||||
class AbstractInternalCommand < AbstractCommand
|
||||
def self.command_name
|
||||
super.sub(/^internal_/i, "_")
|
||||
end
|
||||
@ -1,6 +1,6 @@
|
||||
module Hbc
|
||||
class CLI
|
||||
class Audit < Base
|
||||
class Audit < AbstractCommand
|
||||
def self.help
|
||||
"verifies installability of Casks"
|
||||
end
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
module Hbc
|
||||
class CLI
|
||||
class Cat < Base
|
||||
class Cat < AbstractCommand
|
||||
def self.run(*args)
|
||||
new(*args).run
|
||||
end
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
module Hbc
|
||||
class CLI
|
||||
class Cleanup < Base
|
||||
class Cleanup < AbstractCommand
|
||||
OUTDATED_DAYS = 10
|
||||
OUTDATED_TIMESTAMP = Time.now - (60 * 60 * 24 * OUTDATED_DAYS)
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
module Hbc
|
||||
class CLI
|
||||
class Create < Base
|
||||
class Create < AbstractCommand
|
||||
def self.run(*args)
|
||||
new(*args).run
|
||||
end
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
module Hbc
|
||||
class CLI
|
||||
class Doctor < Base
|
||||
class Doctor < AbstractCommand
|
||||
def self.run
|
||||
ohai "Homebrew-Cask Version", Hbc.full_version
|
||||
ohai "Homebrew-Cask Install Location", render_install_location
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
module Hbc
|
||||
class CLI
|
||||
class Edit < Base
|
||||
class Edit < AbstractCommand
|
||||
def self.run(*args)
|
||||
new(*args).run
|
||||
end
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
module Hbc
|
||||
class CLI
|
||||
class Fetch < Base
|
||||
class Fetch < AbstractCommand
|
||||
def self.run(*args)
|
||||
new(*args).run
|
||||
end
|
||||
|
||||
@ -1,10 +1,6 @@
|
||||
module Hbc
|
||||
class CLI
|
||||
class Home < Base
|
||||
def self.run(*args)
|
||||
new(*args).run
|
||||
end
|
||||
|
||||
class Home < AbstractCommand
|
||||
def run
|
||||
casks = @args.map(&CaskLoader.public_method(:load))
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
module Hbc
|
||||
class CLI
|
||||
class Info < Base
|
||||
class Info < AbstractCommand
|
||||
def self.run(*args)
|
||||
new(*args).run
|
||||
end
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
module Hbc
|
||||
class CLI
|
||||
class Install < Base
|
||||
class Install < AbstractCommand
|
||||
def self.run(*args)
|
||||
new(*args).run
|
||||
end
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
module Hbc
|
||||
class CLI
|
||||
class InternalAppcastCheckpoint < InternalUseBase
|
||||
class InternalAppcastCheckpoint < AbstractInternalCommand
|
||||
def self.run(*args)
|
||||
new(*args).run
|
||||
end
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
module Hbc
|
||||
class CLI
|
||||
class InternalAuditModifiedCasks < InternalUseBase
|
||||
class InternalAuditModifiedCasks < AbstractInternalCommand
|
||||
RELEVANT_STANZAS = [:version, :sha256, :url, :appcast].freeze
|
||||
|
||||
def self.needs_init?
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
module Hbc
|
||||
class CLI
|
||||
class InternalCheckurl < InternalUseBase
|
||||
class InternalCheckurl < AbstractInternalCommand
|
||||
def self.run(*args)
|
||||
new(*args).run
|
||||
end
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
module Hbc
|
||||
class CLI
|
||||
class InternalDump < InternalUseBase
|
||||
class InternalDump < AbstractInternalCommand
|
||||
def self.run(*args)
|
||||
new(*args).run
|
||||
end
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
module Hbc
|
||||
class CLI
|
||||
class InternalHelp < InternalUseBase
|
||||
class InternalHelp < AbstractInternalCommand
|
||||
def self.run(*args)
|
||||
new(*args).run
|
||||
end
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
module Hbc
|
||||
class CLI
|
||||
class InternalStanza < InternalUseBase
|
||||
class InternalStanza < AbstractInternalCommand
|
||||
# Syntax
|
||||
#
|
||||
# brew cask _stanza <stanza_name> [ --table | --yaml | --inspect | --quiet ] [ <cask_token> ... ]
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
module Hbc
|
||||
class CLI
|
||||
class List < Base
|
||||
class List < AbstractCommand
|
||||
def self.run(*args)
|
||||
new(*args).run
|
||||
end
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
module Hbc
|
||||
class CLI
|
||||
class Outdated < Base
|
||||
class Outdated < AbstractCommand
|
||||
def self.run(*args)
|
||||
new(*args).run
|
||||
end
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
module Hbc
|
||||
class CLI
|
||||
class Search < Base
|
||||
class Search < AbstractCommand
|
||||
def self.run(*args)
|
||||
new(*args).run
|
||||
end
|
||||
|
||||
@ -2,15 +2,11 @@ require "English"
|
||||
|
||||
module Hbc
|
||||
class CLI
|
||||
class Style < Base
|
||||
class Style < AbstractCommand
|
||||
def self.help
|
||||
"checks Cask style using RuboCop"
|
||||
end
|
||||
|
||||
def self.run(*args)
|
||||
new(*args).run
|
||||
end
|
||||
|
||||
attr_reader :args
|
||||
def initialize(*args)
|
||||
@cask_tokens = self.class.cask_tokens_from(args)
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
module Hbc
|
||||
class CLI
|
||||
class Uninstall < Base
|
||||
class Uninstall < AbstractCommand
|
||||
def self.run(*args)
|
||||
new(*args).run
|
||||
end
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
module Hbc
|
||||
class CLI
|
||||
class Zap < Base
|
||||
class Zap < AbstractCommand
|
||||
def self.run(*args)
|
||||
new(*args).run
|
||||
end
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
require "cask/lib/hbc/cli/base"
|
||||
require "cask/lib/hbc/cli/abstract_command"
|
||||
|
||||
module Hbc
|
||||
class CLI
|
||||
class Update < Base
|
||||
class Update < AbstractCommand
|
||||
def self.run(*_ignored)
|
||||
odeprecated "`brew cask update`", "`brew update`", disable_on: Time.utc(2017, 7, 1)
|
||||
result = SystemCommand.run(HOMEBREW_BREW_FILE, args: ["update"],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user