Skip to content

Commit

Permalink
Add --cwd <dir> option for setting working directory.
Browse files Browse the repository at this point in the history
  • Loading branch information
nhjschulz committed Aug 29, 2024
1 parent 40b6bcc commit d90bfc9
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/MainNative/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <stdio.h>
#include <getopt.h>
#include <string.h>
#include <unistd.h>
#include <Arduino.h>
#include <Board.h>
#include <RobotDeviceNames.h>
Expand Down Expand Up @@ -77,6 +78,7 @@ static void systemDelay(unsigned long ms);
static const struct option LONG_OPTIONS[] = {{"help", no_argument, nullptr, 0},
{"serialRxCh", required_argument, nullptr, 0},
{"serialTxCh", required_argument, nullptr, 0},
{"cwd", required_argument, nullptr, 0},
{nullptr, no_argument, nullptr, 0}}; /* Marks the end. */

/** Program argument default value of the robot name. */
Expand Down Expand Up @@ -263,6 +265,10 @@ static int handleCommandLineArguments(PrgArguments& prgArguments, int argc, char
{
prgArguments.serialTxChannel = optarg;
}
else if (0 == strcmp(LONG_OPTIONS[optionIndex].name, "cwd"))
{
chdir(optarg);
}
else
{
status = -1;
Expand Down Expand Up @@ -307,6 +313,7 @@ static int handleCommandLineArguments(PrgArguments& prgArguments, int argc, char
printf("\t--serialTxCh <CHANNEL>\t\tSet serial tx channel (ZumoComSystem)."); /* Serial txchannel */
printf(" Default: %s\n", PRG_ARG_SERIAL_TX_CH_DEFAULT); /* Serial tx channel default value */
printf("\t-v\t\t\tVerbose mode. Default: Disabled\n"); /* Flag */
printf("\t--cwd <dir>\t\tSpecify working directory."); /* Set process working directory */
}

return status;
Expand Down

0 comments on commit d90bfc9

Please sign in to comment.