Skip to content

Commit

Permalink
Merge pull request #1348 from rrotter/cmd-completion
Browse files Browse the repository at this point in the history
enforce limit of one subcommand, list named_args
  • Loading branch information
MikeMcQuaid committed Apr 24, 2024
2 parents 8678985 + e2b56b3 commit ca1ff53
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cmd/bundle.rb
Expand Up @@ -92,13 +92,20 @@ class BundleCmd < AbstractCommand
description: "`dump` does not add `restart_service` to formula lines."
switch "--zap",
description: "`cleanup` casks using the `zap` command instead of `uninstall`."

named_args %w[install dump cleanup check exec list]
end

def run
# Keep this inside `run` to keep --help fast.
require_relative "../lib/bundle"

case subcommand = args.named.first.presence
subcommand = args.named.first.presence
if subcommand != "exec" && args.named.size > 1
raise UsageError, "This command does not take more than 1 subcommand argument."
end

case subcommand
when nil, "install"
Bundle::Commands::Install.run(
global: args.global?,
Expand Down

0 comments on commit ca1ff53

Please sign in to comment.