@@ -208,12 +208,12 @@ void parseCliArguments(
208208 Options &options)
209209{
210210 // Parse argument with getopt https://man7.org/linux/man-pages/man3/getopt.3.html
211- const char * short_options = " hsn:c: " ;
211+ const char * short_options = " hsnc " ;
212212 static struct option long_options[] = {
213- {" help" , no_argument , NULL , ' h' },
214- {" unixsocket" , no_argument , NULL , ' s' },
215- {" namespace" , required_argument , NULL , ' n' },
216- {" container_name" , required_argument , NULL , ' c' },
213+ {" help" , optional_argument , NULL , ' h' },
214+ {" unixsocket" , optional_argument , NULL , ' s' },
215+ {" namespace" , optional_argument , NULL , ' n' },
216+ {" container_name" , optional_argument , NULL , ' c' },
217217 // The last element of the array has to be filled with zeros.
218218 {0 , 0 , 0 , 0 }
219219 };
@@ -235,9 +235,10 @@ void parseCliArguments(
235235 break ;
236236
237237 case ' n' :
238- if (optarg )
238+ if (optind < argc )
239239 {
240- options.m_namespace = optarg;
240+ options.m_namespace = argv[optind];
241+ optind++;
241242 }
242243 else
243244 {
@@ -246,9 +247,10 @@ void parseCliArguments(
246247 break ;
247248
248249 case ' c' :
249- if (optarg )
250+ if (optind < argc )
250251 {
251- options.m_container_name = optarg;
252+ options.m_container_name = argv[optind];
253+ optind++;
252254 }
253255 else
254256 {
0 commit comments