Skip to content

Commit

Permalink
added random seed parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
janjurca committed Jan 8, 2025
1 parent 6d73da7 commit 8a16962
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions standalone/source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ void displayHelp() {
std::cout << "Options:\n"
<< " -h, --help Display this help message\n"
<< " -v, --version Display version information\n"
<< " -l, --log level Set the log level (trace, debug, info, warn, error, critical, off)" << std::endl;
<< " -l, --log level Set the log level (trace, debug, info, warn, error, critical, off) (default info)\n"
<< " -s, --seed seed Set the seed for the random number generator (default 42)" << std::endl;
}

void displayVersion() { std::cout << FILESTORM_VERSION << std::endl; }
Expand All @@ -35,8 +36,10 @@ auto main(int argc, char** argv) -> int {
displayHelp();
return 1;
}
srand(42);

const struct option long_options[] = {{"help", no_argument, NULL, 'h'}, {"version", no_argument, NULL, 'v'}, {"log", required_argument, NULL, 'l'}, {NULL, 0, NULL, 0}};
const struct option long_options[]
= {{"help", no_argument, NULL, 'h'}, {"version", no_argument, NULL, 'v'}, {"log", required_argument, NULL, 'l'}, {"seed", required_argument, NULL, 's'}, {NULL, 0, NULL, 0}};
int opt;
while ((opt = getopt_long(argc, argv, "+hvl:", long_options, NULL)) != -1) {
switch (opt) {
Expand All @@ -52,6 +55,10 @@ auto main(int argc, char** argv) -> int {
// Set the log level
spdlog::set_level(spdlog::level::from_str(optarg));
break;
case 's':
// Set the seed for the random number generator
srand(atoi(optarg));
break;
case '?':
// Handle unknown options or missing arguments
break;
Expand Down

0 comments on commit 8a16962

Please sign in to comment.