Automagically remove -cmd suffix
This commit is contained in:
parent
97370b4e6a
commit
821f2a5ab5
@ -17,7 +17,7 @@ module Homebrew
|
|||||||
|
|
||||||
class << self
|
class << self
|
||||||
sig { returns(String) }
|
sig { returns(String) }
|
||||||
def command_name = Utils.underscore(T.must(name).split("::").fetch(-1)).tr("_", "-")
|
def command_name = Utils.underscore(T.must(name).split("::").fetch(-1)).tr("_", "-").delete_suffix("-cmd")
|
||||||
|
|
||||||
# @return the AbstractCommand subclass associated with the brew CLI command name.
|
# @return the AbstractCommand subclass associated with the brew CLI command name.
|
||||||
sig { params(name: String).returns(T.nilable(T.class_of(AbstractCommand))) }
|
sig { params(name: String).returns(T.nilable(T.class_of(AbstractCommand))) }
|
||||||
|
|||||||
@ -8,9 +8,6 @@ require "cli/parser"
|
|||||||
module Homebrew
|
module Homebrew
|
||||||
module DevCmd
|
module DevCmd
|
||||||
class FormulaCmd < AbstractCommand
|
class FormulaCmd < AbstractCommand
|
||||||
sig { returns(String) }
|
|
||||||
def self.command_name = "formula"
|
|
||||||
|
|
||||||
cmd_args do
|
cmd_args do
|
||||||
description <<~EOS
|
description <<~EOS
|
||||||
Display the path where <formula> is located.
|
Display the path where <formula> is located.
|
||||||
|
|||||||
@ -10,9 +10,6 @@ require "livecheck/strategy"
|
|||||||
module Homebrew
|
module Homebrew
|
||||||
module DevCmd
|
module DevCmd
|
||||||
class LivecheckCmd < AbstractCommand
|
class LivecheckCmd < AbstractCommand
|
||||||
sig { returns(String) }
|
|
||||||
def self.command_name = "livecheck"
|
|
||||||
|
|
||||||
cmd_args do
|
cmd_args do
|
||||||
description <<~EOS
|
description <<~EOS
|
||||||
Check for newer versions of formulae and/or casks from upstream.
|
Check for newer versions of formulae and/or casks from upstream.
|
||||||
|
|||||||
@ -39,6 +39,11 @@ RSpec.describe Homebrew::AbstractCommand do
|
|||||||
expect(described_class.command("test-cat")).to be(TestCat)
|
expect(described_class.command("test-cat")).to be(TestCat)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "removes -cmd suffix from command name" do
|
||||||
|
require "dev-cmd/formula"
|
||||||
|
expect(Homebrew::DevCmd::FormulaCmd.command_name).to eq("formula")
|
||||||
|
end
|
||||||
|
|
||||||
describe "when command name is overridden" do
|
describe "when command name is overridden" do
|
||||||
before do
|
before do
|
||||||
tac = Class.new(described_class) do
|
tac = Class.new(described_class) do
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user