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