rev |
line source |
devi@23
|
1 package l3config;
|
devi@23
|
2
|
devi@23
|
3 use Exporter;
|
devi@23
|
4 use Getopt::Long;
|
devi@23
|
5
|
devi@23
|
6 @ISA = ('Exporter');
|
devi@23
|
7 @EXPORT = qw(%Config &init_config);
|
devi@23
|
8
|
devi@23
|
9 our $Config_File = "labmaker.conf";
|
devi@23
|
10 our %Config = (
|
devi@23
|
11 "skip_empty" => "yes",
|
devi@23
|
12 "skip_interrupted" => "no",
|
devi@23
|
13 "skip_wrong" => "no",
|
devi@23
|
14 "editors" => ["vi", "pico", "ee", "vim"],
|
devi@23
|
15 "pagers" => ["more", "less", "zmore", "zless", "info",
|
devi@23
|
16 "man", "mc", "trafshow", "screen", "cfdisk",
|
devi@23
|
17 "trafshow-bsd", "yes", "lynx", "links", "centericq"
|
devi@23
|
18 ],
|
devi@23
|
19 "terminal" => ["mc"],
|
devi@23
|
20 "suppress_editors" => "yes",
|
devi@23
|
21 "suppress_pagers" => "yes",
|
devi@23
|
22 "suppress_terminal" => "yes",
|
devi@23
|
23
|
devi@23
|
24 "terminal_width" => 100,
|
devi@23
|
25 "terminal_height" => 100,
|
devi@23
|
26 "verbose" => "yes",
|
devi@23
|
27
|
devi@23
|
28 "head_lines" => 5,
|
devi@23
|
29 "tail_lines" => 5,
|
devi@23
|
30 "cache_head_lines" => 5,
|
devi@23
|
31 "cache_tail_lines" => 5,
|
devi@23
|
32 "skip_text" => "...",
|
devi@23
|
33 "show_time" => "yes",
|
devi@23
|
34 "show_diffs" => "yes",
|
devi@23
|
35 "show_comments" => "yes",
|
devi@23
|
36
|
devi@23
|
37 "input" => "/root/.labmaker",
|
devi@23
|
38 "diffs" => "",
|
devi@23
|
39 "input_mask" => "*.script",
|
devi@23
|
40 "encoding" => "utf-8",
|
devi@23
|
41
|
devi@23
|
42 "cache" => "/tmp/report.xml",
|
devi@23
|
43
|
devi@23
|
44 "output" => "/tmp/report.html",
|
devi@23
|
45 #"output" => "report.xml",
|
devi@23
|
46 "output_mask" => "INDEX",
|
devi@23
|
47 "output_format" => "html",
|
devi@23
|
48
|
devi@23
|
49 "signature" => "#lm:",
|
devi@23
|
50 "from" => "",
|
devi@23
|
51 "to" => "",
|
devi@23
|
52 "lab" => "",
|
devi@23
|
53 "keywords" => "linux command",
|
devi@23
|
54 "files_keywords" => "linux file",
|
devi@23
|
55
|
devi@23
|
56 comment_width => "300",
|
devi@23
|
57 time_width => "60",
|
devi@23
|
58
|
devi@23
|
59 "course-name" => "",
|
devi@23
|
60 "course-code" => "",
|
devi@23
|
61 "course-date" => "",
|
devi@23
|
62 "course-center" => "",
|
devi@23
|
63 "course-trainer" => "",
|
devi@23
|
64 "course-student" => "",
|
devi@23
|
65 );
|
devi@23
|
66
|
devi@23
|
67 sub read_config_file
|
devi@23
|
68 {
|
devi@23
|
69 my $config = $_[0];
|
devi@23
|
70 my $filename = $_[1];
|
devi@23
|
71 open(CONFIG, "$filename")
|
devi@23
|
72 or return;
|
devi@23
|
73 while (<CONFIG>) {
|
devi@23
|
74 s/#.*//;
|
devi@23
|
75 next if /^\s*$/;
|
devi@23
|
76 my ($var, $val) = split /\s*=\s*/, $_, 2;
|
devi@23
|
77 $var =~ s/\s*//;
|
devi@23
|
78 $config->{$var} = $val;
|
devi@23
|
79 }
|
devi@23
|
80 close(CONFIG);
|
devi@23
|
81 }
|
devi@23
|
82
|
devi@23
|
83
|
devi@23
|
84 sub init_config
|
devi@23
|
85 {
|
devi@23
|
86 my %argv_config;
|
devi@23
|
87 my %file_config;
|
devi@23
|
88 read_config_file(\%file_config, $Config_File);
|
devi@23
|
89 GetOptions(\%argv_config, map "$_=s", keys %Config);
|
devi@23
|
90 %Config = (%Config, %file_config, %argv_config);
|
devi@23
|
91 }
|
devi@23
|
92
|