File tree Expand file tree Collapse file tree 1 file changed +36
-3
lines changed Expand file tree Collapse file tree 1 file changed +36
-3
lines changed Original file line number Diff line number Diff line change
1
+ import argparse
1
2
import itertools
2
3
import os
3
4
import sqlite3
@@ -66,14 +67,46 @@ def setup_sqlite(data_dir: str, db_file: str) -> bool:
66
67
return True
67
68
68
69
69
- def main ():
70
+ def setup_args ():
70
71
"""
71
- Run the SQLite loader utility
72
+ Setup command line arguments
72
73
"""
74
+
73
75
db_path = DISK_LOCATION_DEFAULT / DBNAME
74
76
parent_dir = os .path .dirname (os .path .dirname (os .path .abspath (__file__ )))
75
77
data_dir = os .path .join (parent_dir , "data" )
76
- if not setup_sqlite (data_dir , db_path ):
78
+
79
+ parser = argparse .ArgumentParser (description = "mismatch loader" )
80
+ parser .add_argument (
81
+ "--dir" ,
82
+ metavar = "DATA_DIR" ,
83
+ type = str ,
84
+ default = data_dir ,
85
+ help = "Data folder location" ,
86
+ )
87
+ parser .add_argument (
88
+ "--database" ,
89
+ "-db" ,
90
+ type = str ,
91
+ default = db_path ,
92
+ help = "SQLite DB file location" ,
93
+ )
94
+ args = parser .parse_args ()
95
+ return args
96
+
97
+
98
+ def main ():
99
+ """
100
+ Run the SQLite loader utility
101
+ """
102
+ args = setup_args ()
103
+
104
+ if not os .path .exists (args .dir ) or not os .path .isdir (args .dir ):
105
+ LOGGER .error (
106
+ f"Specified data directory does not exist or is not a folder: { args .dir } "
107
+ )
108
+ exit (1 )
109
+ if not setup_sqlite (args .dir , args .database ):
77
110
exit (1 )
78
111
exit (0 )
79
112
You can’t perform that action at this time.
0 commit comments