achiurizo / consular

Terminal automation
http://rdoc.info/github/achiu/consular/master/file/README.md
MIT License
813 stars 46 forks source link

DOCUMENTATION: how to use dynamically? #96

Open lastobelus opened 12 years ago

lastobelus commented 12 years ago

I'm confused about how to go about using consular dynamically.

For example, say I have some command that returns a list of nodes in a cluster with their ip address. The number of nodes can vary, and the ip addresses are dynamic. How would I use consular to open a tab for each node and ssh to the node's ip address?

achiurizo commented 12 years ago

The consular script are just ruby scripts with the consular DSL available to them. A simple example:


class Foo
  def self.ips
    %w{foo bar fizz buzz}
  end
end

Foo.ips.each do |word|
  tab "echo #{word}"
end
lastobelus commented 12 years ago

I guess I didn't make myself entirely clear. What I mean is, how would I use consular dynamically in some generic script, without creating a project file? What would I have to do to use the above class without going through bin/consular?

achiurizo commented 12 years ago

I'd suggest taking a look at the other consular cores source. The cores are the main entry point into the execution of the commands and takes a hash that's being generated by Consular::DSL. To be frank, I didn't think about using it outside of the CLI. So their are some caveats with this, namely the DSL expects a file to load to generate the appropriate hash. You could do things.

I hope this helps, I'll probably need to rework this a bit in the future as this use case those make sense.