-
Notifications
You must be signed in to change notification settings - Fork 1
Writing Plan Files
By default, planfiles use a very simple DSL that will feel familiar to anyone that's ever used Rake. The biggest difference between Rake (and similar tools) and Mastermind is that Mastermind has no support for dependent tasks or parallel tasks. If your workflow requires either of those things, Mastermind is probably not the tool you want to use. Or, rather, not the only tool you want to use.
Example:
plot :calculator do
description 'Add numbers together'
plan :add do |args|
puts args.map(&:to_i).reduce(&:+)
end
description 'Multiply numbers together'
plan :mutliply do |args|
puts args.map(&:to_i).reduce(&:*)
end
description 'Perform an arbitrary calculation'
plan :calculate, Calculator::Calculate
alias :calc
end
Creates a Plan that contains children with the given name
. This is similar
to the namespace
command in a Rakefile. The Plans created inside the block
are added as children of this Plan.
Provides a description for the next Plan created. Plans created with plot
can also have descriptions.
Creates a Plan with the given name.
If passed a class, that class must implement the Plan interface. The easiest way to do this is to include
CLI::Mastermind::Plan::Interface
in your class.
If passed a block, that block is used to create an instance of CLI::Masterplan::Plan
with the block as its action.
In either case, when called, any plan arguments are passed to the action as an array with no processing done. You can process these arguments however you like from there.
Creates an alias for the most recently defined plan. IMPORTANT: Planfile aliases are defined after user aliases and cannot override them. Alias expansion only occurs during argument processing and cannot be used when programmaticly executing a plan.
This is provided as a convenience for use-cases when a particular alias is already well defined, such as when transitioning from a different tool.
For most other cases, it's recommended that you not define aliases for you plans and allow users to define aliases as they see fit.
For more information, see Alias Expansion