Skip to content

Commit 06d19cb

Browse files
committed
fix: fix input validation and improve error handling in main function
1 parent c783984 commit 06d19cb

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

scanner/src/app.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ void App::defaultActions() {
283283
}
284284

285285
// if file mode is enabled, and no input file is specified, throw an exception
286-
if (!interactiveMode && inputFilePath.empty()) {
286+
if (!interactiveMode && inputFilePath.empty() && !showHelp) {
287287
throw std::invalid_argument("Input file not specified, use -h or --help for usage information.");
288288
}
289289

scanner/src/mian.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,17 @@
55

66
#include "app.hpp"
77

8-
int main(int argc, char *argv[])
9-
{
8+
int main(int argc, char *argv[]) {
109
// Create an App object and run the application
11-
try
12-
{
10+
try {
1311
TINY::SCANNER::App app(argc, argv);
1412
app.run();
15-
}
16-
catch (std::exception &e)
17-
{
13+
} catch (std::exception &e) {
1814
// set color to red
1915
std::cout << "\033[1;31m";
2016
std::cerr << "Error: " << e.what() << std::endl;
17+
// reset
18+
std::cout << "\033[0m";
2119
return EXIT_FAILURE;
2220
}
2321
return EXIT_SUCCESS;

0 commit comments

Comments
 (0)