2023-08-08 13:54:59 -07:00
|
|
|
# typed: strict
|
2019-04-19 15:38:03 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2024-03-29 16:25:28 -07:00
|
|
|
require "abstract_command"
|
2019-01-20 20:42:15 +05:30
|
|
|
|
2014-06-18 22:41:47 -05:00
|
|
|
module Homebrew
|
2024-03-29 16:25:28 -07:00
|
|
|
module Cmd
|
|
|
|
class CommandsCmd < AbstractCommand
|
|
|
|
cmd_args do
|
|
|
|
description <<~EOS
|
|
|
|
Show lists of built-in and external commands.
|
|
|
|
EOS
|
|
|
|
switch "-q", "--quiet",
|
|
|
|
description: "List only the names of commands without category headers."
|
|
|
|
switch "--include-aliases",
|
|
|
|
depends_on: "--quiet",
|
|
|
|
description: "Include aliases of internal commands."
|
|
|
|
|
|
|
|
named_args :none
|
|
|
|
end
|
|
|
|
|
|
|
|
sig { override.void }
|
|
|
|
def run
|
|
|
|
if args.quiet?
|
|
|
|
puts Formatter.columns(Commands.commands(aliases: args.include_aliases?))
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
prepend_separator = T.let(false, T::Boolean)
|
|
|
|
|
|
|
|
{
|
|
|
|
"Built-in commands" => Commands.internal_commands,
|
|
|
|
"Built-in developer commands" => Commands.internal_developer_commands,
|
|
|
|
"External commands" => Commands.external_commands,
|
|
|
|
}.each do |title, commands|
|
|
|
|
next if commands.blank?
|
|
|
|
|
|
|
|
puts if prepend_separator
|
|
|
|
ohai title, Formatter.columns(commands)
|
|
|
|
|
|
|
|
prepend_separator ||= true
|
|
|
|
end
|
|
|
|
end
|
2020-07-20 13:18:09 -04:00
|
|
|
end
|
2015-07-09 19:50:53 +08:00
|
|
|
end
|
2013-09-14 16:58:26 -07:00
|
|
|
end
|