Rename Cask::CLI to Cask::Cmd.

This commit is contained in:
Mike McQuaid 2018-09-04 08:45:48 +01:00
parent 1d86d7a7c7
commit 1ae2326984
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70
47 changed files with 81 additions and 81 deletions

View File

@ -31,7 +31,7 @@ require "cask/cmd/internal_help"
require "cask/cmd/internal_stanza"
module Hbc
class CLI
class Cmd
ALIASES = {
"ls" => "list",
"homepage" => "home",
@ -232,10 +232,10 @@ module Hbc
end
def usage
max_command_len = CLI.commands.map(&:length).max
max_command_len = Cmd.commands.map(&:length).max
puts "Commands:\n\n"
CLI.command_classes.each do |klass|
Cmd.command_classes.each do |klass|
next unless klass.visible
puts " #{klass.command_name.ljust(max_command_len)} #{_help_for(klass)}"
end

View File

@ -1,5 +1,5 @@
module Hbc
class CLI
class Cmd
class Version < AbstractCommand
def self.command_name
"--#{super}"

View File

@ -2,7 +2,7 @@ require_relative "options"
require "search"
module Hbc
class CLI
class Cmd
class AbstractCommand
include Options
include Homebrew::Search

View File

@ -1,5 +1,5 @@
module Hbc
class CLI
class Cmd
class AbstractInternalCommand < AbstractCommand
def self.command_name
super.sub(/^internal_/i, "_")

View File

@ -1,5 +1,5 @@
module Hbc
class CLI
class Cmd
class Audit < AbstractCommand
option "--download", :download, false
option "--token-conflicts", :token_conflicts, false

View File

@ -1,5 +1,5 @@
module Hbc
class CLI
class Cmd
class Cat < AbstractCommand
def initialize(*)
super

View File

@ -1,5 +1,5 @@
module Hbc
class CLI
class Cmd
class Create < AbstractCommand
def initialize(*)
super

View File

@ -2,7 +2,7 @@ require "system_config"
require "cask/checkable"
module Hbc
class CLI
class Cmd
class Doctor < AbstractCommand
include Checkable

View File

@ -1,5 +1,5 @@
module Hbc
class CLI
class Cmd
class Edit < AbstractCommand
def initialize(*)
super

View File

@ -1,7 +1,7 @@
require "cask/download"
module Hbc
class CLI
class Cmd
class Fetch < AbstractCommand
option "--force", :force, false

View File

@ -1,5 +1,5 @@
module Hbc
class CLI
class Cmd
class Home < AbstractCommand
def run
if casks.none?

View File

@ -1,7 +1,7 @@
require "json"
module Hbc
class CLI
class Cmd
class Info < AbstractCommand
option "--json=VERSION", :json

View File

@ -1,5 +1,5 @@
module Hbc
class CLI
class Cmd
class Install < AbstractCommand
option "--force", :force, false
option "--skip-cask-deps", :skip_cask_deps, false

View File

@ -1,5 +1,5 @@
module Hbc
class CLI
class Cmd
class InternalHelp < AbstractInternalCommand
def initialize(*)
super
@ -8,9 +8,9 @@ module Hbc
end
def run
max_command_len = CLI.commands.map(&:length).max
max_command_len = Cmd.commands.map(&:length).max
puts "Unstable Internal-use Commands:\n\n"
CLI.command_classes.each do |klass|
Cmd.command_classes.each do |klass|
next if klass.visible
puts " #{klass.command_name.ljust(max_command_len)} #{self.class.help_for(klass)}"
end

View File

@ -1,5 +1,5 @@
module Hbc
class CLI
class Cmd
class InternalStanza < AbstractInternalCommand
# Syntax
#

View File

@ -1,5 +1,5 @@
module Hbc
class CLI
class Cmd
class List < AbstractCommand
option "-1", :one, false
option "--versions", :versions, false

View File

@ -1,5 +1,5 @@
module Hbc
class CLI
class Cmd
module Options
def self.included(klass)
klass.extend(ClassMethods)

View File

@ -1,5 +1,5 @@
module Hbc
class CLI
class Cmd
class Outdated < AbstractCommand
option "--greedy", :greedy, false
option "--quiet", :quiet, false

View File

@ -1,5 +1,5 @@
module Hbc
class CLI
class Cmd
class Reinstall < Install
def run
casks.each do |cask|

View File

@ -1,5 +1,5 @@
module Hbc
class CLI
class Cmd
class Style < AbstractCommand
def self.help
"checks Cask style using RuboCop"

View File

@ -1,5 +1,5 @@
module Hbc
class CLI
class Cmd
class Uninstall < AbstractCommand
option "--force", :force, false

View File

@ -1,5 +1,5 @@
module Hbc
class CLI
class Cmd
class Upgrade < AbstractCommand
option "--greedy", :greedy, false
option "--quiet", :quiet, false

View File

@ -1,5 +1,5 @@
module Hbc
class CLI
class Cmd
class Zap < AbstractCommand
option "--force", :force, false

View File

@ -4,6 +4,6 @@ module Homebrew
module_function
def cask
Hbc::CLI.run(*ARGV)
Hbc::Cmd.run(*ARGV)
end
end

View File

@ -4,7 +4,7 @@ require "cleanup"
using CleanupRefinement
module Hbc
class CLI
class Cmd
class Cleanup < AbstractCommand
OUTDATED_DAYS = 10
OUTDATED_TIMESTAMP = Time.now - (60 * 60 * 24 * OUTDATED_DAYS)

View File

@ -2,7 +2,7 @@ require "cask/cmd/abstract_command"
require "cmd/search"
module Hbc
class CLI
class Cmd
module Compat
class Search < AbstractCommand
def run

View File

@ -1,4 +1,4 @@
describe Hbc::CLI::Version, :cask do
describe Hbc::Cmd::Version, :cask do
describe "::run" do
it "outputs the current Homebrew Cask version" do
expect { described_class.run }

View File

@ -1,6 +1,6 @@
require_relative "shared_examples/invalid_option"
describe Hbc::CLI::Audit, :cask do
describe Hbc::Cmd::Audit, :cask do
let(:cask) { Hbc::Cask.new(nil) }
it_behaves_like "a command that handles invalid options"

View File

@ -1,7 +1,7 @@
require_relative "shared_examples/requires_cask_token"
require_relative "shared_examples/invalid_option"
describe Hbc::CLI::Cat, :cask do
describe Hbc::Cmd::Cat, :cask do
it_behaves_like "a command that requires a Cask token"
it_behaves_like "a command that handles invalid options"

View File

@ -1,7 +1,7 @@
require_relative "shared_examples/requires_cask_token"
require_relative "shared_examples/invalid_option"
describe Hbc::CLI::Create, :cask do
describe Hbc::Cmd::Create, :cask do
around do |example|
begin
example.run

View File

@ -1,17 +1,17 @@
require_relative "shared_examples/invalid_option"
describe Hbc::CLI::Doctor, :cask do
describe Hbc::Cmd::Doctor, :cask do
it_behaves_like "a command that handles invalid options"
it "displays some nice info about the environment" do
expect {
Hbc::CLI::Doctor.run
Hbc::Cmd::Doctor.run
}.to output(/\A==> Homebrew Cask Version/).to_stdout
end
it "raises an exception when arguments are given" do
expect {
Hbc::CLI::Doctor.run("argument")
Hbc::Cmd::Doctor.run("argument")
}.to raise_error(ArgumentError)
end
end

View File

@ -1,7 +1,7 @@
require_relative "shared_examples/requires_cask_token"
require_relative "shared_examples/invalid_option"
describe Hbc::CLI::Edit, :cask do
describe Hbc::Cmd::Edit, :cask do
before do
allow_any_instance_of(described_class).to receive(:exec_editor)
end

View File

@ -1,7 +1,7 @@
require_relative "shared_examples/requires_cask_token"
require_relative "shared_examples/invalid_option"
describe Hbc::CLI::Fetch, :cask do
describe Hbc::Cmd::Fetch, :cask do
let(:local_transmission) {
Hbc::CaskLoader.load(cask_path("local-transmission"))
}

View File

@ -1,6 +1,6 @@
require_relative "shared_examples/invalid_option"
describe Hbc::CLI::Home, :cask do
describe Hbc::Cmd::Home, :cask do
before do
allow(described_class).to receive(:open_url)
end

View File

@ -1,7 +1,7 @@
require_relative "shared_examples/requires_cask_token"
require_relative "shared_examples/invalid_option"
describe Hbc::CLI::Info, :cask do
describe Hbc::Cmd::Info, :cask do
it_behaves_like "a command that requires a Cask token"
it_behaves_like "a command that handles invalid options"

View File

@ -1,7 +1,7 @@
require_relative "shared_examples/requires_cask_token"
require_relative "shared_examples/invalid_option"
describe Hbc::CLI::Install, :cask do
describe Hbc::Cmd::Install, :cask do
it_behaves_like "a command that requires a Cask token"
it_behaves_like "a command that handles invalid options"

View File

@ -1,4 +1,4 @@
describe Hbc::CLI::InternalStanza, :cask do
describe Hbc::Cmd::InternalStanza, :cask do
it "shows stanza of the Specified Cask" do
command = described_class.new("homepage", "local-caffeine")
expect {

View File

@ -1,6 +1,6 @@
require_relative "shared_examples/invalid_option"
describe Hbc::CLI::List, :cask do
describe Hbc::Cmd::List, :cask do
it_behaves_like "a command that handles invalid options"
it "lists the installed Casks in a pretty fashion" do

View File

@ -1,4 +1,4 @@
describe Hbc::CLI, :cask do
describe Hbc::Cmd, :cask do
it "supports setting the appdir" do
allow(Hbc::Config.global).to receive(:appdir).and_call_original

View File

@ -1,6 +1,6 @@
require_relative "shared_examples/invalid_option"
describe Hbc::CLI::Outdated, :cask do
describe Hbc::Cmd::Outdated, :cask do
let(:installed) do
[
Hbc::CaskLoader.load(cask_path("basic-cask")),

View File

@ -9,7 +9,7 @@ describe Hbc::Quarantine, :cask do
describe "by default" do
it "quarantines a nice fresh Cask" do
Hbc::CLI::Install.run("local-transmission")
Hbc::Cmd::Install.run("local-transmission")
expect(
Hbc::CaskLoader.load(cask_path("local-transmission")),
@ -21,7 +21,7 @@ describe Hbc::Quarantine, :cask do
end
it "quarantines Cask fetches" do
Hbc::CLI::Fetch.run("local-transmission")
Hbc::Cmd::Fetch.run("local-transmission")
local_transmission = Hbc::CaskLoader.load(cask_path("local-transmission"))
cached_location = Hbc::Download.new(local_transmission, force: false, quarantine: false).perform
@ -29,7 +29,7 @@ describe Hbc::Quarantine, :cask do
end
it "quarantines Cask audits" do
Hbc::CLI::Audit.run("local-transmission", "--download")
Hbc::Cmd::Audit.run("local-transmission", "--download")
local_transmission = Hbc::CaskLoader.load(cask_path("local-transmission"))
cached_location = Hbc::Download.new(local_transmission, force: false, quarantine: false).perform
@ -38,7 +38,7 @@ describe Hbc::Quarantine, :cask do
end
it "quarantines dmg-based Casks" do
Hbc::CLI::Install.run("container-dmg")
Hbc::Cmd::Install.run("container-dmg")
expect(
Hbc::CaskLoader.load(cask_path("container-dmg")),
@ -48,7 +48,7 @@ describe Hbc::Quarantine, :cask do
end
it "quarantines tar-gz-based Casks" do
Hbc::CLI::Install.run("container-tar-gz")
Hbc::Cmd::Install.run("container-tar-gz")
expect(
Hbc::CaskLoader.load(cask_path("container-tar-gz")),
@ -58,7 +58,7 @@ describe Hbc::Quarantine, :cask do
end
it "quarantines xar-based Casks" do
Hbc::CLI::Install.run("container-xar")
Hbc::Cmd::Install.run("container-xar")
expect(
Hbc::CaskLoader.load(cask_path("container-xar")),
@ -68,7 +68,7 @@ describe Hbc::Quarantine, :cask do
end
it "quarantines pure bzip2-based Casks" do
Hbc::CLI::Install.run("container-bzip2")
Hbc::Cmd::Install.run("container-bzip2")
expect(
Hbc::CaskLoader.load(cask_path("container-bzip2")),
@ -78,7 +78,7 @@ describe Hbc::Quarantine, :cask do
end
it "quarantines pure gzip-based Casks" do
Hbc::CLI::Install.run("container-gzip")
Hbc::Cmd::Install.run("container-gzip")
expect(
Hbc::CaskLoader.load(cask_path("container-gzip")),
@ -88,7 +88,7 @@ describe Hbc::Quarantine, :cask do
end
it "quarantines the pkg in naked-pkg-based Casks" do
Hbc::CLI::Install.run("container-pkg")
Hbc::Cmd::Install.run("container-pkg")
naked_pkg = Hbc::CaskLoader.load(cask_path("container-pkg"))
@ -100,7 +100,7 @@ describe Hbc::Quarantine, :cask do
end
it "quarantines a nested container" do
Hbc::CLI::Install.run("nested-app")
Hbc::Cmd::Install.run("nested-app")
expect(
Hbc::CaskLoader.load(cask_path("nested-app")),
@ -112,7 +112,7 @@ describe Hbc::Quarantine, :cask do
describe "when disabled" do
it "does not quarantine even a nice, fresh Cask" do
Hbc::CLI::Install.run("local-transmission", "--no-quarantine")
Hbc::Cmd::Install.run("local-transmission", "--no-quarantine")
expect(
Hbc::CaskLoader.load(cask_path("local-transmission")),
@ -122,7 +122,7 @@ describe Hbc::Quarantine, :cask do
end
it "does not quarantine Cask fetches" do
Hbc::CLI::Fetch.run("local-transmission", "--no-quarantine")
Hbc::Cmd::Fetch.run("local-transmission", "--no-quarantine")
local_transmission = Hbc::CaskLoader.load(cask_path("local-transmission"))
cached_location = Hbc::Download.new(local_transmission, force: false, quarantine: false).perform
@ -130,7 +130,7 @@ describe Hbc::Quarantine, :cask do
end
it "does not quarantine dmg-based Casks" do
Hbc::CLI::Install.run("container-dmg", "--no-quarantine")
Hbc::Cmd::Install.run("container-dmg", "--no-quarantine")
expect(
Hbc::CaskLoader.load(cask_path("container-dmg")),
@ -140,7 +140,7 @@ describe Hbc::Quarantine, :cask do
end
it "does not quarantine tar-gz-based Casks" do
Hbc::CLI::Install.run("container-tar-gz", "--no-quarantine")
Hbc::Cmd::Install.run("container-tar-gz", "--no-quarantine")
expect(
Hbc::CaskLoader.load(cask_path("container-tar-gz")),
@ -150,7 +150,7 @@ describe Hbc::Quarantine, :cask do
end
it "does not quarantine xar-based Casks" do
Hbc::CLI::Install.run("container-xar", "--no-quarantine")
Hbc::Cmd::Install.run("container-xar", "--no-quarantine")
expect(
Hbc::CaskLoader.load(cask_path("container-xar")),
@ -160,7 +160,7 @@ describe Hbc::Quarantine, :cask do
end
it "does not quarantine pure bzip2-based Casks" do
Hbc::CLI::Install.run("container-bzip2", "--no-quarantine")
Hbc::Cmd::Install.run("container-bzip2", "--no-quarantine")
expect(
Hbc::CaskLoader.load(cask_path("container-bzip2")),
@ -170,7 +170,7 @@ describe Hbc::Quarantine, :cask do
end
it "does not quarantine pure gzip-based Casks" do
Hbc::CLI::Install.run("container-gzip", "--no-quarantine")
Hbc::Cmd::Install.run("container-gzip", "--no-quarantine")
expect(
Hbc::CaskLoader.load(cask_path("container-gzip")),
@ -180,7 +180,7 @@ describe Hbc::Quarantine, :cask do
end
it "does not quarantine the pkg in naked-pkg-based Casks" do
Hbc::CLI::Install.run("container-pkg", "--no-quarantine")
Hbc::Cmd::Install.run("container-pkg", "--no-quarantine")
naked_pkg = Hbc::CaskLoader.load(cask_path("container-pkg"))
@ -192,7 +192,7 @@ describe Hbc::Quarantine, :cask do
end
it "does not quarantine a nested container" do
Hbc::CLI::Install.run("nested-app", "--no-quarantine")
Hbc::Cmd::Install.run("nested-app", "--no-quarantine")
expect(
Hbc::CaskLoader.load(cask_path("nested-app")),
@ -202,7 +202,7 @@ describe Hbc::Quarantine, :cask do
end
it "does not quarantine Cask audits" do
Hbc::CLI::Audit.run("local-transmission", "--download", "--no-quarantine")
Hbc::Cmd::Audit.run("local-transmission", "--download", "--no-quarantine")
local_transmission = Hbc::CaskLoader.load(cask_path("local-transmission"))
cached_location = Hbc::Download.new(local_transmission, force: false, quarantine: false).perform

View File

@ -1,6 +1,6 @@
require_relative "shared_examples/invalid_option"
describe Hbc::CLI::Reinstall, :cask do
describe Hbc::Cmd::Reinstall, :cask do
it_behaves_like "a command that handles invalid options"
it "displays the reinstallation progress" do
@ -22,23 +22,23 @@ describe Hbc::CLI::Reinstall, :cask do
EOS
expect {
Hbc::CLI::Reinstall.run("local-caffeine")
Hbc::Cmd::Reinstall.run("local-caffeine")
}.to output(output).to_stdout
end
it "allows reinstalling a Cask" do
Hbc::CLI::Install.run("local-transmission")
Hbc::Cmd::Install.run("local-transmission")
expect(Hbc::CaskLoader.load(cask_path("local-transmission"))).to be_installed
Hbc::CLI::Reinstall.run("local-transmission")
Hbc::Cmd::Reinstall.run("local-transmission")
expect(Hbc::CaskLoader.load(cask_path("local-transmission"))).to be_installed
end
it "allows reinstalling a non installed Cask" do
expect(Hbc::CaskLoader.load(cask_path("local-transmission"))).not_to be_installed
Hbc::CLI::Reinstall.run("local-transmission")
Hbc::Cmd::Reinstall.run("local-transmission")
expect(Hbc::CaskLoader.load(cask_path("local-transmission"))).to be_installed
end
end

View File

@ -3,7 +3,7 @@ require "rubygems"
require_relative "shared_examples/invalid_option"
describe Hbc::CLI::Style, :cask do
describe Hbc::Cmd::Style, :cask do
let(:args) { [] }
let(:cli) { described_class.new(*args) }

View File

@ -1,7 +1,7 @@
require_relative "shared_examples/requires_cask_token"
require_relative "shared_examples/invalid_option"
describe Hbc::CLI::Uninstall, :cask do
describe Hbc::Cmd::Uninstall, :cask do
it_behaves_like "a command that requires a Cask token"
it_behaves_like "a command that handles invalid options"

View File

@ -1,6 +1,6 @@
require_relative "shared_examples/invalid_option"
describe Hbc::CLI::Upgrade, :cask do
describe Hbc::Cmd::Upgrade, :cask do
it_behaves_like "a command that handles invalid options"
context "successful upgrade" do
@ -14,7 +14,7 @@ describe Hbc::CLI::Upgrade, :cask do
}
before do
installed.each { |cask| Hbc::CLI::Install.run(cask) }
installed.each { |cask| Hbc::Cmd::Install.run(cask) }
allow_any_instance_of(described_class).to receive(:verbose?).and_return(true)
end
@ -177,7 +177,7 @@ describe Hbc::CLI::Upgrade, :cask do
}
before do
installed.each { |cask| Hbc::CLI::Install.run(cask) }
installed.each { |cask| Hbc::Cmd::Install.run(cask) }
allow_any_instance_of(described_class).to receive(:verbose?).and_return(true)
end

View File

@ -1,7 +1,7 @@
require_relative "shared_examples/requires_cask_token"
require_relative "shared_examples/invalid_option"
describe Hbc::CLI::Zap, :cask do
describe Hbc::Cmd::Zap, :cask do
it_behaves_like "a command that requires a Cask token"
it_behaves_like "a command that handles invalid options"

View File

@ -1,4 +1,4 @@
describe Hbc::CLI, :cask do
describe Hbc::Cmd, :cask do
it "lists the taps for Casks that show up in two taps" do
listing = described_class.nice_listing(%w[
homebrew/cask/adium
@ -28,13 +28,13 @@ describe Hbc::CLI, :cask do
context "when no option is specified" do
it "--binaries is true by default" do
command = Hbc::CLI::Install.new("some-cask")
command = Hbc::Cmd::Install.new("some-cask")
expect(command.binaries?).to be true
end
end
context "::run" do
let(:noop_command) { double("CLI::Noop") }
let(:noop_command) { double("Cmd::Noop") }
before do
allow(described_class).to receive(:lookup_command).with("noop").and_return(noop_command)
@ -42,7 +42,7 @@ describe Hbc::CLI, :cask do
end
it "passes `--version` along to the subcommand" do
version_command = double("CLI::Version")
version_command = double("Cmd::Version")
allow(described_class).to receive(:lookup_command).with("--version").and_return(version_command)
expect(described_class).to receive(:run_command).with(version_command)
described_class.run("--version")