]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - bin/rbot
* we're now "git version", not "svn version" by default
[user/henk/code/ruby/rbot.git] / bin / rbot
index 98bc333938d2bb9168b88487b095f7b1e44c6358..6d8ecec39e2f6cd501a114bb3f7b7819a4cd19ef 100755 (executable)
--- a/bin/rbot
+++ b/bin/rbot
@@ -1,5 +1,41 @@
 #!/usr/bin/env ruby
 
+=begin rdoc
+
+= rbot main executable
+
+Usage:
+
+  % rbot [options] [config directory]
+
+== Options
+
+[-h, --help]
+    display a help message and exit
+[-v, --version]
+    display version information and exit
+[-d, --debug]
+    enable debug messages
+[-l, --loglevel _level_]
+    sets the minimum log level verbosity
+[-b, --background]
+    background (daemonize) the bot
+[-p, --pidfile _filename_]
+    write the bot pid to _filename_
+
+The default config directory is <tt>~/.rbot</tt>.
+
+The default pidfile is <tt><i>botdir</i>/rbot.pid</tt>.
+
+The logfile is located at <tt><i>botdir</i>/<i>botname</i>.log</tt>, and
+the default loglevel is 1 (INFO messages). Possible values for the loglevel
+are 0 (DEBUG), 1 (INFO), 2 (WARN), 3 (ERROR), 4 (FATAL).
+
+Please note that the logfile doesn't contain IRC logs (which are located at
+<tt><i>botdir</i>/logs/*</tt>, but only rbot diagnostic messages.
+
+=end
+
 # Copyright (C) 2002 Tom Gilbert.
 #
 # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -38,25 +74,30 @@ require 'etc'
 require 'getoptlong'
 require 'fileutils'
 
-$version="0.9.11-svn"
+$version="0.9.11-git"
 $opts = Hash.new
 
-if $version =~ /svn/
-  if defined?(SVN_DIR) and File.exists?(File.join(SVN_DIR, '.git'))
-    $version.sub!('svn', 'git')
-
+if $version =~ /git/
+  if defined?(SCM_DIR) and File.exists?(File.join(SCM_DIR, '.git'))
     git_out = `git status`
 
     git_out.match(/^# On branch (.*)\n/)
-    branch = $1.dup || "unknown"
-    changed = git_out.match(/^# Change(.*)\n/)
-    rev = "revision "
-    git_out = `git log -1 --pretty=format:"%h%n%b"`.split("\n")
-    rev << git_out.first
-    if git_out.last.match(/^git-svn-id: \S+@(\d+)/)
-      rev << "(svn #{$1})"
+    if $1 # git 1.5.x
+      branch = $1.dup || "unknown"
+      changed = git_out.match(/^# Change(.*)\n/)
+      rev = "revision "
+      git_out = `git log -1 --pretty=format:"%h%n%b"`.split("\n")
+      rev << git_out.first
+      if git_out.last.match(/^git-svn-id: \S+@(\d+)/)
+        rev << "(svn #{$1})"
+      end
+      rev << ", local changes" if changed
+    else # older gits
+      git_out = `git branch`
+      git_out.match(/^\* (.*)\n/)
+      branch = $1.dup rescue "unknown"
+      rev = "revision " + `git rev-parse HEAD`[0,6]
     end
-    rev << ", local changes" if changed
 
     $version << " (#{branch} branch, #{rev})"
   else
@@ -91,7 +132,7 @@ opts = GetoptLong.new(
   ["--version", "-v", GetoptLong::NO_ARGUMENT]
 )
 
-$debug = false
+$debug = $DEBUG
 $daemonize = false
 
 opts.each {|opt, arg|
@@ -136,8 +177,9 @@ if ($opts["help"])
   puts "  -h, --help         this message"
   puts "  -v, --version      version information"
   puts "  -d, --debug        enable debug messages"
+  puts "  -l, --loglevel     sets the log level verbosity"
   puts "  -b, --background   background (daemonize) the bot"
-  puts "  -p, --pidfile      write the bot pid to this file"
+  puts "  -p, --pidfile      write the bot pid to file"
   puts "config directory defaults to ~/.rbot"
   exit 0
 end