mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Port Homebrew::Cmd::CommandsCmd
This commit is contained in:
parent
adf47bb11b
commit
02e2772e9d
@ -1,14 +1,12 @@
|
||||
# typed: strict
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "cli/parser"
|
||||
require "abstract_command"
|
||||
|
||||
module Homebrew
|
||||
module_function
|
||||
|
||||
sig { returns(CLI::Parser) }
|
||||
def commands_args
|
||||
Homebrew::CLI::Parser.new do
|
||||
module Cmd
|
||||
class CommandsCmd < AbstractCommand
|
||||
cmd_args do
|
||||
description <<~EOS
|
||||
Show lists of built-in and external commands.
|
||||
EOS
|
||||
@ -20,12 +18,9 @@ module Homebrew
|
||||
|
||||
named_args :none
|
||||
end
|
||||
end
|
||||
|
||||
sig { void }
|
||||
def commands
|
||||
args = commands_args.parse
|
||||
|
||||
sig { override.void }
|
||||
def run
|
||||
if args.quiet?
|
||||
puts Formatter.columns(Commands.commands(aliases: args.include_aliases?))
|
||||
return
|
||||
@ -46,4 +41,6 @@ module Homebrew
|
||||
prepend_separator ||= true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,11 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "cmd/commands"
|
||||
require "fileutils"
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
RSpec.describe "brew commands" do
|
||||
RSpec.describe Homebrew::Cmd::CommandsCmd do
|
||||
it_behaves_like "parseable arguments"
|
||||
|
||||
it "prints a list of all available commands", :integration_test do
|
||||
|
Loading…
x
Reference in New Issue
Block a user