extend shell_parameter argument

This commit is contained in:
Max Eisner 2022-07-24 23:03:28 +02:00
parent 92bccd2074
commit 1c059e1da0
No known key found for this signature in database
GPG Key ID: 4BF122C22879F0C8

View File

@ -1642,7 +1642,7 @@ class Formula
shells: [:bash, :zsh, :fish], shells: [:bash, :zsh, :fish],
executable: bin/base_name, executable: bin/base_name,
cmd: "completion", cmd: "completion",
shell_parameter: nil) shell_parameter_format: nil)
completion_script_path_map = { completion_script_path_map = {
bash: bash_completion/base_name, bash: bash_completion/base_name,
zsh: zsh_completion/"_#{base_name}", zsh: zsh_completion/"_#{base_name}",
@ -1651,12 +1651,16 @@ class Formula
shells.each do |shell| shells.each do |shell|
script_path = completion_script_path_map[shell] script_path = completion_script_path_map[shell]
shell_parameter = if shell_parameter.nil? shell_parameter = if shell_parameter_format.nil?
shell.to_s shell.to_s
elsif shell_parameter == :flag elsif shell_parameter_format == :flag
"--#{shell}" "--#{shell}"
elsif shell_parameter_format == :arg
"--shell=#{shell}"
elsif shell_parameter_format == :none
nil
else else
"#{shell_parameter}#{shell}" "#{shell_parameter_format}#{shell}"
end end
script_path.dirname.mkpath script_path.dirname.mkpath