Merge pull request #14218 from EricFromCanada/create-prompt-name
dev-cmd/create: also prompt for name when run with `--cask`
This commit is contained in:
commit
4fe0d085bc
@ -85,11 +85,15 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def create_cask(args:)
|
def create_cask(args:)
|
||||||
raise UsageError, "The `--set-name` flag is required for creating casks." if args.set_name.blank?
|
|
||||||
|
|
||||||
url = args.named.first
|
url = args.named.first
|
||||||
name = args.set_name
|
name = if args.set_name.blank?
|
||||||
token = Cask::Utils.token_from(args.set_name)
|
stem = Pathname.new(url).stem.rpartition("=").last
|
||||||
|
print "Cask name [#{stem}]: "
|
||||||
|
__gets || stem
|
||||||
|
else
|
||||||
|
args.set_name
|
||||||
|
end
|
||||||
|
token = Cask::Utils.token_from(name)
|
||||||
|
|
||||||
cask_tap = Tap.fetch(args.tap || "homebrew/cask")
|
cask_tap = Tap.fetch(args.tap || "homebrew/cask")
|
||||||
raise TapUnavailableError, args.tap unless cask_tap.installed?
|
raise TapUnavailableError, args.tap unless cask_tap.installed?
|
||||||
@ -139,13 +143,19 @@ module Homebrew
|
|||||||
|
|
||||||
def create_formula(args:)
|
def create_formula(args:)
|
||||||
fc = FormulaCreator.new(args)
|
fc = FormulaCreator.new(args)
|
||||||
fc.name = args.set_name
|
fc.name = if args.set_name.blank?
|
||||||
|
stem = Pathname.new(args.named.first).stem.rpartition("=").last
|
||||||
|
print "Formula name [#{stem}]: "
|
||||||
|
__gets || stem
|
||||||
|
else
|
||||||
|
args.set_name
|
||||||
|
end
|
||||||
fc.version = args.set_version
|
fc.version = args.set_version
|
||||||
fc.license = args.set_license
|
fc.license = args.set_license
|
||||||
fc.tap = Tap.fetch(args.tap || "homebrew/core")
|
fc.tap = Tap.fetch(args.tap || "homebrew/core")
|
||||||
raise TapUnavailableError, args.tap unless fc.tap.installed?
|
raise TapUnavailableError, args.tap unless fc.tap.installed?
|
||||||
|
|
||||||
fc.url = args.named.first # Pull the first (and only) URL from ARGV
|
fc.url = args.named.first
|
||||||
|
|
||||||
fc.mode = if args.autotools?
|
fc.mode = if args.autotools?
|
||||||
:autotools
|
:autotools
|
||||||
@ -169,13 +179,6 @@ module Homebrew
|
|||||||
:rust
|
:rust
|
||||||
end
|
end
|
||||||
|
|
||||||
if fc.name.nil? || fc.name.strip.empty?
|
|
||||||
stem = Pathname.new(fc.url).stem.rpartition("=").last
|
|
||||||
print "Formula name [#{stem}]: "
|
|
||||||
fc.name = __gets || stem
|
|
||||||
fc.update_path
|
|
||||||
end
|
|
||||||
|
|
||||||
# Check for disallowed formula, or names that shadow aliases,
|
# Check for disallowed formula, or names that shadow aliases,
|
||||||
# unless --force is specified.
|
# unless --force is specified.
|
||||||
unless args.force?
|
unless args.force?
|
||||||
|
@ -10,7 +10,7 @@ describe "brew create" do
|
|||||||
it_behaves_like "parseable arguments"
|
it_behaves_like "parseable arguments"
|
||||||
|
|
||||||
it "creates a new Formula file for a given URL", :integration_test do
|
it "creates a new Formula file for a given URL", :integration_test do
|
||||||
brew "create", url, "HOMEBREW_EDITOR" => "/bin/cat"
|
brew "create", "--set-name=Testball", url, "HOMEBREW_EDITOR" => "/bin/cat"
|
||||||
|
|
||||||
expect(formula_file).to exist
|
expect(formula_file).to exist
|
||||||
expect(formula_file.read).to match(%Q(sha256 "#{TESTBALL_SHA256}"))
|
expect(formula_file.read).to match(%Q(sha256 "#{TESTBALL_SHA256}"))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user