Third party gems can register before and after callbacks to enhance a command.
Example
From the foo gem we have a command hello.
#!/usr/bin/env ruby
extend Dry::CLI::Registry
argument :name, required: true
puts "hello "
end
end
end
end
end
Foo::CLI::Commands.register "hello", Foo::CLI::Commands::Hello
cli = Dry::CLI.new(Foo::CLI::Commands)
cli.call
The foo-bar gem enhances hello command with callbacks:
Foo::CLI::Commands.before("hello") { puts "debug: " } # syntax 1
Foo::CLI::Commands.after "hello", &->(args) { puts "bye, " } # syntax 2