You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for your work on this project mdub! I really like it. Question: Is it possible to share parameters via modules. I've tried the following but the parameter doesn't appear in the help for my command nor does its attribute get set. What am I missing?
module SharedParameters
extend Clamp::Parameter::Declaration
parameter "NAME", "name of thing"
def thing
System.get(name).status
end
end
class StatusCommand
include ShareParameters
def execute
puts thing
end
end
class MainCommand < Clamp::Command
subcommand "status", "show status of thing", StatusCommand
end
The text was updated successfully, but these errors were encountered:
No, it's not possible to include parameter declarations via a module, in the way you'd include options.
You'll have to use a different trick to declare shared parameters, e.g.
Clampdoclass << selfdefdeclare_name_parameterparameter"NAME","name of thing"endendsubcommand"foo","Do foo"dodeclare_name_parameterdefexecuteputs"foo"endendend
Another alternative is to declare the parameter before subcommands, if it applies to all of them. This is the approach I prefer, though it does alters the usage:
Clampdoparameter"NAME","name of thing"subcommand"foo","Do foo"dodefexecuteputs"foo"endendend
Thanks for your work on this project mdub! I really like it. Question: Is it possible to share parameters via modules. I've tried the following but the parameter doesn't appear in the help for my command nor does its attribute get set. What am I missing?
The text was updated successfully, but these errors were encountered: