mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Port Homebrew::Cmd::CompletionsCmd
This commit is contained in:
parent
02e2772e9d
commit
b97f9b22e2
@ -1,15 +1,13 @@
|
|||||||
# typed: strict
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "cli/parser"
|
require "abstract_command"
|
||||||
require "completions"
|
require "completions"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
module_function
|
module Cmd
|
||||||
|
class CompletionsCmd < AbstractCommand
|
||||||
sig { returns(CLI::Parser) }
|
cmd_args do
|
||||||
def completions_args
|
|
||||||
Homebrew::CLI::Parser.new do
|
|
||||||
description <<~EOS
|
description <<~EOS
|
||||||
Control whether Homebrew automatically links external tap shell completion files.
|
Control whether Homebrew automatically links external tap shell completion files.
|
||||||
Read more at <https://docs.brew.sh/Shell-Completion>.
|
Read more at <https://docs.brew.sh/Shell-Completion>.
|
||||||
@ -23,12 +21,9 @@ module Homebrew
|
|||||||
|
|
||||||
named_args %w[state link unlink], max: 1
|
named_args %w[state link unlink], max: 1
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
sig { void }
|
|
||||||
def completions
|
|
||||||
args = completions_args.parse
|
|
||||||
|
|
||||||
|
sig { override.void }
|
||||||
|
def run
|
||||||
case args.named.first
|
case args.named.first
|
||||||
when nil, "state"
|
when nil, "state"
|
||||||
if Completions.link_completions?
|
if Completions.link_completions?
|
||||||
@ -46,4 +41,6 @@ module Homebrew
|
|||||||
raise UsageError, "unknown subcommand: #{args.named.first}"
|
raise UsageError, "unknown subcommand: #{args.named.first}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "cmd/completions"
|
||||||
require "cmd/shared_examples/args_parse"
|
require "cmd/shared_examples/args_parse"
|
||||||
|
|
||||||
RSpec.describe "brew completions" do
|
RSpec.describe Homebrew::Cmd::CompletionsCmd do
|
||||||
it_behaves_like "parseable arguments"
|
it_behaves_like "parseable arguments"
|
||||||
|
|
||||||
it "runs the status subcommand correctly", :integration_test do
|
it "runs the status subcommand correctly", :integration_test do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user