@@ -19,10 +19,18 @@ static bool no_duplicates;
1919static bool no_footer ;
2020static bool no_header ;
2121
22+ static const struct option long_options [] = {
23+ {"bare" , no_argument , NULL , 'b' },
24+ {"help" , no_argument , NULL , 'h' },
25+ {"no-duplicates" , no_argument , NULL , 'n' },
26+ {0 , 0 , 0 , 0 }
27+ };
28+
2229static const char labwc_menu_generator_usage [] =
2330"Usage: labwc-menu-generator [options...]\n"
24- " -h show help message and quit\n"
25- " -n limit desktop entries to one directory only\n" ;
31+ " -b, --bare Show no header or footer\n"
32+ " -h, --help Show help message and quit\n"
33+ " -n, --no-duplicates Limit desktop entries to one directory only\n" ;
2634
2735static void
2836usage (void )
263271main (int argc , char * * argv )
264272{
265273 int c ;
266- while ((c = getopt (argc , argv , "bhn" )) != -1 ) {
274+ while (1 ) {
275+ int index = 0 ;
276+ c = getopt_long (argc , argv , "bhn" , long_options , & index );
277+ if (c == -1 ) {
278+ break ;
279+ }
267280 switch (c ) {
268281 case 'b' :
269282 no_footer = true;
@@ -277,6 +290,9 @@ main(int argc, char **argv)
277290 usage ();
278291 }
279292 }
293+ if (optind < argc ) {
294+ usage ();
295+ }
280296
281297 GList * apps = desktop_entries_create ();
282298 GList * dirs = directory_entries_create ();
0 commit comments