You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I made a samiliar use as the dd-style example.
the code is following, the project name is server:
int main(int argc, char **argv)
{
args::ArgumentParser parser("push the commands");
parser.LongPrefix("");
parser.LongSeparator("=");
args::HelpFlag help(parser, "HELP", "Show this help menu.", { "help" });
args::ValueFlagstd::string logs_dir(parser, "Path", " Logs Directory", { "-log", "-LogPath" });
try
{
parser.ParseCLI(argc, argv);
}
catch (args::Help)
{
std::cout << parser;
return 0;
}
catch (args::ParseError e)
{
std::cerr << e.what() << std::endl;
std::cerr << parser;
return 1;
}
catch (args::ValidationError e)
{
std::cerr << e.what() << std::endl;
std::cerr << parser;
return 1;
}
if (logs_dir)
{
std::cout << "if = " << args::get(logs_dir) << std::endl;
}
}
than I ues the command to started the program in windows(the exe name is server):
./server.exe -log=server_1\logs
the output is:
if = server_1\logs
Then I built a linux program in Ubuntu 20.04 LTS, I started the program :
./server -log=server_1\logs
the output is:
if = server_1logs
The '' has been disappered
So how can I fix this problem?
Thank you!
The text was updated successfully, but these errors were encountered:
That is probably actually your shell eating it, as backslashes are typically used as escape characters. If you surround the argument in single-quotes, the backslash won't get eaten (double quotes may or may not help, depending on your shell). But you're right, Linux paths do use forward slashes.
I made a samiliar use as the dd-style example.
the code is following, the project name is server:
int main(int argc, char **argv)
{
args::ArgumentParser parser("push the commands");
parser.LongPrefix("");
parser.LongSeparator("=");
args::HelpFlag help(parser, "HELP", "Show this help menu.", { "help" });
args::ValueFlagstd::string logs_dir(parser, "Path", " Logs Directory", { "-log", "-LogPath" });
try
{
parser.ParseCLI(argc, argv);
}
catch (args::Help)
{
std::cout << parser;
return 0;
}
catch (args::ParseError e)
{
std::cerr << e.what() << std::endl;
std::cerr << parser;
return 1;
}
catch (args::ValidationError e)
{
std::cerr << e.what() << std::endl;
std::cerr << parser;
return 1;
}
if (logs_dir)
{
std::cout << "if = " << args::get(logs_dir) << std::endl;
}
}
than I ues the command to started the program in windows(the exe name is server):
./server.exe -log=server_1\logs
the output is:
if = server_1\logs
Then I built a linux program in Ubuntu 20.04 LTS, I started the program :
./server -log=server_1\logs
the output is:
if = server_1logs
The '' has been disappered
So how can I fix this problem?
Thank you!
The text was updated successfully, but these errors were encountered: