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