Initial working prototype
[aids.git] / bin / aids
1 #!/usr/bin/ruby1.8
2
3 require 'lib/aids'
4
5 def main(argv)
6         svc = AIDS::Service.new(argv[1]) if argv[1]
7         case argv[0]
8                 when 'enable'
9                         usage unless svc
10                         svc.enable!
11                 when 'disable'
12                         usage unless svc
13                         svc.disable!
14                 when 'list'
15                         if svc
16                                 puts svc.status
17                         else
18                                 AIDS.get_all_services.sort_by{|s|s.name}.each do |s|
19                                         puts "#{s.name}: #{s.status}"
20                                 end
21                         end
22                 else
23                         usage
24         end
25 end
26
27 def usage
28         $stderr.puts <<-EOF
29 AIDS - Assistant for Initialisation of Debian Services
30
31 Usage: #{$0} command [service]
32
33 Command may be one of:
34
35   - enable
36       Enables the service.
37
38   - disable
39       Disables the service.
40
41   - list
42       Lists the current status of the service, or of all services if
43       none is provided.
44         EOF
45         exit 1
46 end
47
48 main(ARGV) if $0 == __FILE__