<\/p>\n\r\n require 'bond'\r\n Bond.start\r\n\r\n Bond.complete(:method => \"rpc\") do |e|\r\n begin\r\n if e.argument == 1\r\n if e.arguments.last == \"?\"\r\n puts \"\\n\\nActions for #{@agent_name}:\\n\"\r\n\r\n @agent.ddl.actions.each do |action|\r\n puts \"%20s - %s\" % [ \":#{action}\", @agent.ddl.action_interface(action)[:description] ] \r\n end\r\n\r\n print \"\\n\" + e.line\r\n end\r\n\r\n @agent.ddl.actions\r\n\r\n elsif e.argument > 1\r\n action = eval(e.arguments[0]).to_s\r\n ddl = @agent.ddl.action_interface(action)\r\n\r\n if e.arguments.last == \"?\"\r\n puts \"\\n\\nArguments for #{action}:\\n\"\r\n ddl[:input].keys.each do |input|\r\n puts \"%20s - %s\" % [ \":#{input}\", ddl[:input][input][:description] ]\r\n end\r\n\r\n print \"\\n\" + e.line\r\n end\r\n\r\n ddl[:input].keys\r\n end\r\n rescue Exception \r\n []\r\n end\r\n end\r\n<\/pre>\n<\/code><\/p>\n
This code checks the argument count, handles the first and subsequent arguments differently and supports the ?<\/em> special case by loading the DDL and displaying the right stuff. <\/p>\nI’ve not found much by way of complex examples on the Bond site or its own bundled completions, hopefully this helps someone.<\/p>\n","protected":false},"excerpt":{"rendered":"
I’ve had a pipe dream of creating something like IRB for ruby but tailored for mcollective, something with DDL assisted completion and all sorts of crazy kewl things. Having looked a few times into this I concluded IRB is a black box of undocumented voodoo and always gave up. I had another google this weekend […]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","footnotes":""},"categories":[1],"tags":[121,78,13],"_links":{"self":[{"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/posts\/1780"}],"collection":[{"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/comments?post=1780"}],"version-history":[{"count":3,"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/posts\/1780\/revisions"}],"predecessor-version":[{"id":1783,"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/posts\/1780\/revisions\/1783"}],"wp:attachment":[{"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/media?parent=1780"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/categories?post=1780"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/tags?post=1780"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}