cli/parser: Improve single or multi "-" detection
- This reads nicer (to me).
This commit is contained in:
parent
570a660758
commit
27afcf5779
@ -533,8 +533,8 @@ module Homebrew
|
||||
|
||||
class OptionConstraintError < UsageError
|
||||
def initialize(arg1, arg2, missing: false)
|
||||
arg1 = arg1.length > 1 ? "--#{arg1.tr("_", "-")}" : "-#{arg1.tr("_", "-")}"
|
||||
arg2 = arg2.length > 1 ? "--#{arg2.tr("_", "-")}" : "-#{arg2.tr("_", "-")}"
|
||||
arg1 = dashes(arg1) + arg1.tr("_", "-")
|
||||
arg2 = dashes(arg2) + arg2.tr("_", "-")
|
||||
|
||||
message = if missing
|
||||
"`#{arg2}` cannot be passed without `#{arg1}`."
|
||||
@ -543,6 +543,10 @@ module Homebrew
|
||||
end
|
||||
super message
|
||||
end
|
||||
|
||||
def dashes(arg)
|
||||
arg.length > 1 ? "--" : "-"
|
||||
end
|
||||
end
|
||||
|
||||
class OptionConflictError < UsageError
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user