Skip to content

Commit 81dac56

Browse files
authored
feat: added flags for mismatch_loader (#4246)
Signed-off-by: Meet Soni <[email protected]>
1 parent fc3df36 commit 81dac56

File tree

1 file changed

+36
-3
lines changed

1 file changed

+36
-3
lines changed

cve_bin_tool/mismatch_loader.py

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import argparse
12
import itertools
23
import os
34
import sqlite3
@@ -66,14 +67,46 @@ def setup_sqlite(data_dir: str, db_file: str) -> bool:
6667
return True
6768

6869

69-
def main():
70+
def setup_args():
7071
"""
71-
Run the SQLite loader utility
72+
Setup command line arguments
7273
"""
74+
7375
db_path = DISK_LOCATION_DEFAULT / DBNAME
7476
parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
7577
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):
77110
exit(1)
78111
exit(0)
79112

0 commit comments

Comments
 (0)