git ssb

0+

cel / freecheck



Commit feb0e084199fb46a40a769d11a23843969deb0e8

Make config file configurable

Charles Lehner committed on 4/13/2016, 7:19:05 PM
Parent: 3ba59a872b934d08858db3732c17e2ed208b5b4b

Files changed

freecheckchanged
freecheckView
@@ -31,12 +31,8 @@
3131 use Getopt::Long;
3232 use File::Copy qw(copy);
3333
3434
35-if ( ! -e $ConfigFile ) {
36- copy $systemConfigFile, $ConfigFile;
37-}
38-
3935 # This tells us how to format the strings from the cfg file
4036 # so we can print it as a PostScript definition
4137 # The key read will replace "value" for each of these
4238 # Strings are enclosed in parentheses (String) (Foobar)
@@ -113,9 +109,10 @@
113109 );
114110
115111 # Parse command line options and deal with them:
116112
117-GetOptions ("account:s", # Account definition file
113 +GetOptions ("config:s", # Config file
114 + "account:s", # Account definition name
118115 "checknum:i", # Check number optional (overrides acct file)
119116 "pages:i", # Number of pages to print
120117 "checkstyle:s", # Check style (defaults to "normal_style.ps"
121118 "checktype:s", # Check blank definition
@@ -134,8 +131,14 @@
134131 if ($opt_help) {
135132 Show_Usage();
136133 }
137134
135 +if ($opt_config) {
136 + $ConfigFile = $opt_config;
137 +} elsif ( ! -e $ConfigFile ) {
138 + copy $systemConfigFile, $ConfigFile;
139 +}
140 +
138141 # Some defaults...
139142 if (!$opt_cgi) {
140143 $opt_account = "sample" unless defined $opt_account;
141144 $opt_checktype = "MVG3001" unless defined $opt_checktype;
@@ -609,9 +612,9 @@
609612 + ($Definitions{"NumPages"} * $Definitions{"ChecksPerPage"});
610613
611614 $config_file = Replace_Val($config_file, "Account", $opt_account,
612615 "CheckNumber", $next_check_number);
613- write_file ($ENV{"HOME"} . "/.freecheck.cfg", $config_file);
616 + write_file ($ConfigFile, $config_file);
614617 }
615618
616619 ###############
617620 # Subroutines #
@@ -732,9 +735,10 @@
732735 print "\nFreeCheck v.$version - a Free Check printing Utility\n\n";
733736 print "Usage: freecheck <options>:\n";
734737 print "\n";
735738 print "options:\n";
736- print " --account <filename> account to use (default \"$opt_account\")\n";
739 + print " --config <filename> config file (default \"~/.freecheck.cfg\")\n";
740 + print " --account <name> account to use (default \"$opt_account\")\n";
737741 print " --checknum <integer> starting check number (overrides cfg)\n";
738742 print " --pages <integer> number of pages to print (overrides cfg)\n";
739743 print " --checkstyle <filename> check style to use (default \"$opt_checkstyle\")\n";
740744 print " --checktype <filename> blank check type to use (default \"$opt_checktype\")\n";
@@ -747,9 +751,8 @@
747751 print " --preserve print but don't increment check number\n";
748752 print " --test print but don't increment check number\n";
749753 print " and print VOID on the check\n";
750754 print " --cgi accept string from CGI script (see docs)\n";
751- print "\nconfig file \"~/.freecheck.cfg\"\n";
752755 die "\n";
753756 }
754757
755758 sub Print_Defs {

Built with git-ssb-web