make subcmd optional again, formulae like certigo need it
This commit is contained in:
parent
a666b1bce8
commit
19530b2239
@ -1625,7 +1625,7 @@ class Formula
|
|||||||
# Generate shell completions for a formula for bash, zsh, and fish, using the formula's executable.
|
# Generate shell completions for a formula for bash, zsh, and fish, using the formula's executable.
|
||||||
#
|
#
|
||||||
# @param executable [Pathname] the executable to use for generating the completion scripts.
|
# @param executable [Pathname] the executable to use for generating the completion scripts.
|
||||||
# @param subcmd [String] the subcommand to pass to the `executable`.
|
# @param subcmd [String] the subcommand to pass to the `executable`, if any. Defaults to `nil`.
|
||||||
# @param base_name [String] the base name of the generated completion script. Defaults to the formula name.
|
# @param base_name [String] the base name of the generated completion script. Defaults to the formula name.
|
||||||
# @param shells [Array<Symbol>] the shells to generate completion scripts for. Defaults to `[:bash, :zsh, :fish]`.
|
# @param shells [Array<Symbol>] the shells to generate completion scripts for. Defaults to `[:bash, :zsh, :fish]`.
|
||||||
# @param shell_parameter_format [String, Symbol] specify how `shells` should each be passed
|
# @param shell_parameter_format [String, Symbol] specify how `shells` should each be passed
|
||||||
@ -1677,11 +1677,11 @@ class Formula
|
|||||||
# (bash_completion/"foo").write Utils.safe_popen_read({ "SHELL" => "bash" }, bin/"foo",
|
# (bash_completion/"foo").write Utils.safe_popen_read({ "SHELL" => "bash" }, bin/"foo",
|
||||||
# "completions", "--selected-shell=bash")
|
# "completions", "--selected-shell=bash")
|
||||||
sig {
|
sig {
|
||||||
params(executable: Pathname, subcmd: String, base_name: String, shells: T::Array[Symbol],
|
params(executable: Pathname, subcmd: T.nilable(String), base_name: String, shells: T::Array[Symbol],
|
||||||
shell_parameter_format: T.nilable(T.any(Symbol, String))).void
|
shell_parameter_format: T.nilable(T.any(Symbol, String))).void
|
||||||
}
|
}
|
||||||
def generate_completions_from_executable(executable,
|
def generate_completions_from_executable(executable,
|
||||||
subcmd,
|
subcmd = nil,
|
||||||
base_name: name,
|
base_name: name,
|
||||||
shells: [:bash, :zsh, :fish],
|
shells: [:bash, :zsh, :fish],
|
||||||
shell_parameter_format: nil)
|
shell_parameter_format: nil)
|
||||||
@ -1705,8 +1705,13 @@ class Formula
|
|||||||
"#{shell_parameter_format}#{shell}"
|
"#{shell_parameter_format}#{shell}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
popen_read_args = %w[]
|
||||||
|
popen_read_args << executable
|
||||||
|
popen_read_args << subcmd if subcmd.present?
|
||||||
|
popen_read_args << shell_parameter
|
||||||
|
|
||||||
script_path.dirname.mkpath
|
script_path.dirname.mkpath
|
||||||
script_path.write Utils.safe_popen_read({ "SHELL" => shell.to_s }, executable, subcmd, shell_parameter)
|
script_path.write Utils.safe_popen_read({ "SHELL" => shell.to_s }, *popen_read_args)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user