1# Copyright 2012 - 2013, Steve Rader
2# Copyright 2013 - 2014, Scott Kostyshak
3
4sub parse_args {
5  while ( @ARGV ) {
6    if ( $ARGV[0] eq '-help' ) {
7      &usage();
8    }
9    if ( $ARGV[0] eq '-audit' || $ARGV[0] eq '-a' ) {
10      $audit = 1;
11      shift @ARGV;
12      next;
13    }
14    if ( $ARGV[0] eq '-titlebar' || $ARGV[0] eq '-t' ) {
15      $titlebar = 1;
16      shift @ARGV;
17      next;
18    }
19    $cli_args .= "$ARGV[0] ";
20    shift @ARGV;
21    next;
22  }
23  if ( $audit ) {
24    open(AUDIT, ">", "vit_audit.log") or die "$!";
25    open STDERR, '>&AUDIT';
26
27    # flush AUDIT after printing to it
28    my $ofh = select AUDIT;
29    $| = 1;
30    select $ofh;
31
32    print AUDIT "$$ INIT $0 " . join(' ',@ARGV), "\r\n";
33  }
34}
35
36#------------------------------------------------------------------
37
38sub usage {
39  print "usage: vit [switches] [task_args]\n";
40  print "  -audit     print task commands to vit_audit.log\n";
41  print "  -titlebar  sets the xterm titlebar to \"$version\"\n";
42  print "  task_args  any set of task commandline args that print an \"ID\" column\n";
43  exit 1;
44}
45
46return 1;
47
48