Added mcollective 2.3.1 package
[packages/trusty/mcollective.git] / bin / mco
1 #!/usr/bin/env ruby
2
3 require 'mcollective'
4
5 Version = MCollective.version
6 known_applications = MCollective::Applications.list
7
8 # links from mc-ping to mc will result in ping being run
9 if $0 =~ /mc\-([a-zA-Z\-_\.]+)$/
10   app_name = $1
11 else
12   app_name = ARGV.first
13   ARGV.delete_at(0)
14 end
15
16 if known_applications.include?(app_name)
17   # make sure the various options classes shows the right help etc
18   $0 = app_name
19
20   MCollective::Applications.run(app_name)
21 else
22   puts "The Marionette Collective version #{MCollective.version}"
23   puts
24   puts "usage: #{$0} command <options>"
25   puts
26   puts "Known commands:"
27   puts
28
29   known_applications.sort.uniq.in_groups_of(3) do |apps|
30     puts "   %-20s %-20s %-20s" % [apps[0], apps[1], apps[2]]
31   end
32
33   puts
34   puts "Type '#{$0} help' for a detailed list of commands and '#{$0} help command'"
35   puts "to get detailed help for a command"
36   puts
37 end