desc "Deploy the app to the specified environment"
arg :env, [:required]
command :ship do |c|
c.flag :ref, default_value: Dx::Main.git_current_rev, require: true
c.action do |_global, options, args|
current.execute(c.name)
end
end
it gives this error by default:
error: Not enough arguments for command
It would be nice to somehow provide a way for particular commands to override this sort of help message for required arg(s). I looked at subclassing MissingRequiredArgumentsException, but that gets raised too early in GLI's run method to actually raise our own exception.
I was able to do this via patching GLI, which works fine - but I'm wondering if there would be a nice way to specify this in the DSL...maybe something like?
arg :env, [:required], error_message: "`ship` requires a single env to deploy to; for ex: `dx ship pre-prod`"
Here how I patched it for context, which honestly is not bad at all and I definitely run with:
module CustomMissingArgsMessage
def initialize(message, command)
if command.name == :ship
super("error: 'ship' requires a single env to deploy to; for ex 'dx ship pre-prod'", command)
else
super
end
end
end
GLI::MissingRequiredArgumentsException.prepend(CustomMissingArgsMessage)
Given a command like this:
it gives this error by default:
It would be nice to somehow provide a way for particular commands to override this sort of help message for required arg(s). I looked at subclassing
MissingRequiredArgumentsException
, but that gets raised too early in GLI's run method to actually raise our own exception.I was able to do this via patching GLI, which works fine - but I'm wondering if there would be a nice way to specify this in the DSL...maybe something like?
Here how I patched it for context, which honestly is not bad at all and I definitely run with: