Skip to content

Commit a46caa4

Browse files
committed
Add small UX improvements
1 parent eaf2f14 commit a46caa4

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

keyhunter.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,14 @@ def main_keyhunter(haystack_filename: str | Path, log_path: Optional[str | Path]
122122
setup_logging(log_path)
123123
logger.info("Starting keyhunter")
124124

125+
if log_path:
126+
logger.info(f"Logging to console, and file: {log_path}")
127+
else:
128+
logger.info("Logging to console only.")
129+
130+
if not Path(haystack_filename).is_file():
131+
raise FileNotFoundError(f"File not found: {haystack_filename}")
132+
125133
keys = find_keys(haystack_filename)
126134

127135
logger.info(f"Found {len(keys)} keys: {keys}")
@@ -137,13 +145,13 @@ def main_keyhunter(haystack_filename: str | Path, log_path: Optional[str | Path]
137145
def get_args():
138146
parser = argparse.ArgumentParser(description="Find Bitcoin private keys in a file.")
139147
parser.add_argument("filename", help="The file to search for keys.")
140-
parser.add_argument("--log", help="Log file to write logs to.")
148+
parser.add_argument("-l", "--log", dest="log_path", help="Log file to write logs to.")
141149
return parser.parse_args()
142150

143151

144152
def main_cli():
145153
args = get_args()
146-
main_keyhunter(args.filename, log_path=args.log)
154+
main_keyhunter(args.filename, log_path=args.log_path)
147155

148156

149157
if __name__ == "__main__":

0 commit comments

Comments
 (0)