Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions sonic-db-cli/sonic-db-cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,12 @@ void parseCliArguments(
Options &options)
{
// Parse argument with getopt https://man7.org/linux/man-pages/man3/getopt.3.html
const char* short_options = "hsnc";
const char* short_options = "hsn:c:";
static struct option long_options[] = {
{"help", optional_argument, NULL, 'h' },
{"unixsocket", optional_argument, NULL, 's' },
{"namespace", optional_argument, NULL, 'n' },
{"container_name", optional_argument, NULL, 'c' },
{"help", no_argument, NULL, 'h' },
{"unixsocket", no_argument, NULL, 's' },
{"namespace", required_argument, NULL, 'n' },
{"container_name", required_argument, NULL, 'c' },
// The last element of the array has to be filled with zeros.
{0, 0, 0, 0 }
};
Expand All @@ -235,10 +235,9 @@ void parseCliArguments(
break;

case 'n':
if (optind < argc)
if (optarg)
{
options.m_namespace = argv[optind];
optind++;
options.m_namespace = optarg;
}
else
{
Expand All @@ -247,10 +246,9 @@ void parseCliArguments(
break;

case 'c':
if (optind < argc)
if (optarg)
{
options.m_container_name = argv[optind];
optind++;
options.m_container_name = optarg;
}
else
{
Expand Down
Loading