@@ -55,6 +55,7 @@ type CMD_OPTS_PRIVATE
5555 enable_autocache as boolean '' automatically select a cache if none given on the command line
5656 enable_pagelist as boolean '' enable reading in a text file with a list of page names
5757 enable_manual as boolean '' enable the manual dir option
58+ enable_database as boolean '' enable db_* options
5859
5960 print as boolean '' -printopts option on command line
6061
@@ -89,6 +90,21 @@ type CMD_OPTS_PRIVATE
8990 manual as boolean '' -manual_dir given on command line
9091 manual_dir as string '' value of '-manual_dir DIR' given on command line
9192
93+ db_host_is_set as boolean '' -db_host given on command line
94+ db_host as string '' value of '-db_host TEXT' given on command line
95+
96+ db_user_is_set as boolean '' -db_user given on command line
97+ db_user as string '' value of '-db_user TEXT' given on command line
98+
99+ db_pass_is_set as boolean '' -db_pass given on command line
100+ db_pass as string '' value of '-db_pass TEXT' given on command line
101+
102+ db_name_is_set as boolean '' -db_name given on command line
103+ db_name as string '' value of '-db_name TEXT' given on command line
104+
105+ db_port_is_set as boolean '' -db_port given on command line
106+ db_port as integer '' value of '-db_port NUMBER' given on command line
107+
92108end type
93109
94110dim shared cmd_opt as CMD_OPTS_PRIVATE
@@ -107,6 +123,7 @@ sub cmd_opts_init( byval opts_flags as const CMD_OPTS_ENABLE_FLAGS )
107123 cmd_opt.enable_autocache = cbool ( opts_flags and CMD_OPTS_ENABLE_AUTOCACHE )
108124 cmd_opt.enable_pagelist = cbool ( opts_flags and CMD_OPTS_ENABLE_PAGELIST )
109125 cmd_opt.enable_manual = cbool ( opts_flags and CMD_OPTS_ENABLE_MANUAL )
126+ cmd_opt.enable_database = cbool ( opts_flags and CMD_OPTS_ENABLE_DATABASE )
110127
111128 '' general options
112129
@@ -132,6 +149,23 @@ sub cmd_opts_init( byval opts_flags as const CMD_OPTS_ENABLE_FLAGS )
132149 cmd_opt.ca = false '' -certificate given on command line
133150 cmd_opt.ca_file = "" '' value of '-certificate FILE' given on command line
134151
152+ '' database options
153+
154+ cmd_opt.db_host_is_set = false '' -db_host given on command line
155+ cmd_opt.db_host = "" '' value of '-db_host TEXT' given on command line
156+
157+ cmd_opt.db_user_is_set = false '' -db_user given on command line
158+ cmd_opt.db_user = "" '' value of '-db_user TEXT' given on command line
159+
160+ cmd_opt.db_pass_is_set = false '' -db_pass given on command line
161+ cmd_opt.db_pass = "" '' value of '-db_pass TEXT' given on command line
162+
163+ cmd_opt.db_name_is_set = false '' -db_name given on command line
164+ cmd_opt.db_name = "" '' value of '-db_name TEXT' given on command line
165+
166+ cmd_opt.db_port_is_set = false '' -db_port given on command line
167+ cmd_opt.db_port = 0 '' value of '-db_port NUMBER' given on command line
168+
135169 '' login options
136170
137171 cmd_opt.user = false '' -u given on command line
@@ -146,6 +180,8 @@ sub cmd_opts_init( byval opts_flags as const CMD_OPTS_ENABLE_FLAGS )
146180 cmd_opt.manual = false '' -manual_dir given on command line
147181 cmd_opt.manual_dir = "" '' value of '-manual_dir DIR' given on command line
148182
183+ cmd_opt.db_user_is_set = false
184+
149185 '' resolved options
150186
151187 app_opt.wiki_url = "" '' export: resolved wiki url
@@ -156,6 +192,12 @@ sub cmd_opts_init( byval opts_flags as const CMD_OPTS_ENABLE_FLAGS )
156192 app_opt.image_dir = "" '' export: image directory
157193 app_opt.manual_dir = "" '' export: manual directory
158194
195+ app_opt.db_host = "" '' export: database host name
196+ app_opt.db_user = "" '' export: database user name
197+ app_opt.db_pass = "" '' export: database user password
198+ app_opt.db_name = "" '' export: database name
199+ app_opt.db_port = 0 '' export: database port number
200+
159201 app_opt.pageCount = 0
160202 redim app_opt.pageList( 1 to 1 ) as string
161203 redim app_opt.pageComments( 1 to 1 ) as string
@@ -350,6 +392,81 @@ function cmd_opts_read( byref i as integer ) as boolean
350392 return false
351393 end if
352394
395+ case "-db_host"
396+
397+ if ( cmd_opt.enable_database ) then
398+
399+ if ( cmd_opt.db_host_is_set ) then
400+ cmd_opts_duplicate_die( i )
401+ end if
402+ cmd_opt.db_host_is_set = true
403+ i += 1
404+ cmd_opt.db_host = command(i)
405+
406+ else
407+ return false
408+ end if
409+
410+ case "-db_user"
411+
412+ if ( cmd_opt.enable_database ) then
413+
414+ if ( cmd_opt.db_user_is_set ) then
415+ cmd_opts_duplicate_die( i )
416+ end if
417+ cmd_opt.db_user_is_set = true
418+ i += 1
419+ cmd_opt.db_user = command(i)
420+
421+ else
422+ return false
423+ end if
424+
425+ case "-db_pass"
426+
427+ if ( cmd_opt.enable_database ) then
428+
429+ if ( cmd_opt.db_pass_is_set ) then
430+ cmd_opts_duplicate_die( i )
431+ end if
432+ cmd_opt.db_pass_is_set = true
433+ i += 1
434+ cmd_opt.db_pass = command(i)
435+
436+ else
437+ return false
438+ end if
439+
440+ case "-db_name"
441+
442+ if ( cmd_opt.enable_database ) then
443+
444+ if ( cmd_opt.db_name_is_set ) then
445+ cmd_opts_duplicate_die( i )
446+ end if
447+ cmd_opt.db_name_is_set = true
448+ i += 1
449+ cmd_opt.db_name = command(i)
450+
451+ else
452+ return false
453+ end if
454+
455+ case "-db_port"
456+
457+ if ( cmd_opt.enable_database ) then
458+
459+ if ( cmd_opt.db_port_is_set ) then
460+ cmd_opts_duplicate_die( i )
461+ end if
462+ cmd_opt.db_port_is_set = true
463+ i += 1
464+ cmd_opt.db_port = cint ( command(i) )
465+
466+ else
467+ return false
468+ end if
469+
353470 case "-ini"
354471 if ( cmd_opt.ini ) then
355472 cmd_opts_duplicate_die( i )
@@ -421,6 +538,11 @@ function cmd_opts_resolve() as boolean
421538 dim as string dev_pass = ""
422539 dim as string def_image_dir = hardcoded.default_image_dir
423540 dim as string def_manual_dir = hardcoded.default_manual_dir
541+ dim as string db_host = ""
542+ dim as string db_user = ""
543+ dim as string db_pass = ""
544+ dim as string db_name = ""
545+ dim as integer db_port = 3306
424546
425547 '' -ini FILE on the command line overrides the hardcoded value
426548 if ( cmd_opt.ini ) then
@@ -445,6 +567,11 @@ function cmd_opts_resolve() as boolean
445567 dev_pass = opts-> Get ( "dev_password" )
446568 def_image_dir = opts-> Get ( "image_dir" )
447569 def_manual_dir = opts-> Get ( "manual_dir" )
570+ db_host = opts-> Get ( "db_host" )
571+ db_user = opts-> Get ( "db_user" )
572+ db_pass = opts-> Get ( "db_pass" )
573+ db_name = opts-> Get ( "db_name" )
574+ db_port = cint ( opts-> Get ( "db_port" ) )
448575 delete opts
449576 elseif ( cmd_opt.ini ) then
450577 '' if we explicitly gave the -ini FILE option, report the error
@@ -513,6 +640,36 @@ function cmd_opts_resolve() as boolean
513640 app_opt.manual_dir = def_manual_dir
514641 end if
515642
643+ if ( cmd_opt.db_host_is_set ) then
644+ app_opt.db_host = cmd_opt.db_host
645+ else
646+ app_opt.db_host = db_host
647+ end if
648+
649+ if ( cmd_opt.db_user_is_set ) then
650+ app_opt.db_user = cmd_opt.db_user
651+ else
652+ app_opt.db_user = db_user
653+ end if
654+
655+ if ( cmd_opt.db_pass_is_set ) then
656+ app_opt.db_pass = cmd_opt.db_pass
657+ else
658+ app_opt.db_pass = db_pass
659+ end if
660+
661+ if ( cmd_opt.db_name_is_set ) then
662+ app_opt.db_name = cmd_opt.db_name
663+ else
664+ app_opt.db_name = db_name
665+ end if
666+
667+ if ( cmd_opt.db_port_is_set ) then
668+ app_opt.db_port = cmd_opt.db_port
669+ else
670+ app_opt.db_port = db_port
671+ end if
672+
516673 if ( cmd_opt.print ) then
517674
518675 print "ini_file = " & ini_file
@@ -537,6 +694,11 @@ function cmd_opts_resolve() as boolean
537694 print "wiki_password = " & "*****"
538695 print "image_dir = " & app_opt.image_dir
539696 print "manual_dir = " & app_opt.manual_dir
697+ print "db_host = " & app_opt.db_host
698+ print "db_user = " & app_opt.db_user
699+ print "db_pass = " & app_opt.db_pass
700+ print "db_name = " & app_opt.db_name
701+ print "db_port = " & app_opt.db_port
540702 print
541703
542704 end 1
@@ -548,7 +710,7 @@ function cmd_opts_resolve() as boolean
548710end function
549711
550712''
551- function cmd_opts_check () as boolean
713+ function cmd_opts_check_cache () as boolean
552714
553715 if ( cmd_opt.enable_cache ) then
554716 '' check that we have the values we need
@@ -557,6 +719,13 @@ function cmd_opts_check() as boolean
557719 end if
558720 end if
559721
722+ function = true
723+
724+ end function
725+
726+ ''
727+ function cmd_opts_check_url() as boolean
728+
560729 if ( cmd_opt.enable_url ) then
561730 if ( app_opt.wiki_url = "" ) then
562731 cmd_opts_die( "no url specified" )
@@ -567,6 +736,28 @@ function cmd_opts_check() as boolean
567736
568737end function
569738
739+ ''
740+ function cmd_opts_check_database() as boolean
741+
742+ if ( cmd_opt.enable_database ) then
743+ '' check that we have the values we need
744+ if ( app_opt.db_host = "" ) then
745+ cmd_opts_die( "no database host specified" )
746+ elseif ( app_opt.db_user = "" ) then
747+ cmd_opts_die( "no database user login name specified" )
748+ elseif ( app_opt.db_pass = "" ) then
749+ cmd_opts_die( "no database user login password specified" )
750+ elseif ( app_opt.db_name = "" ) then
751+ cmd_opts_die( "no database name specified" )
752+ elseif ( app_opt.db_port = 0 ) then
753+ cmd_opts_die( "no database port specified" )
754+ end if
755+ end if
756+
757+ function = true
758+
759+ end function
760+
570761''
571762sub cmd_opts_show_help_item _
572763 ( _
@@ -655,5 +846,12 @@ sub cmd_opts_show_help( byref action as const string = "", locations as boolean
655846 print " -manual_dir DIR override the manual directory location"
656847 end if
657848
849+ if ( cmd_opt.enable_database ) then
850+ print " -db_host database host name"
851+ print " -db_user database user login name"
852+ print " -db_pass database user login password"
853+ print " -db_name database name"
854+ print " -db_port database port number"
855+ end if
658856
659- end sub
857+ end sub
0 commit comments