Skip to content

Commit e548036

Browse files
author
mancausoft
committed
Avoid duplicate help output
1 parent 0fd3ed2 commit e548036

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/fuse_ods2.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ struct cli_opts {
4343
int lower;
4444
int textmode;
4545
int debug;
46+
int help;
47+
int version;
4648
unsigned uid;
4749
unsigned gid;
4850
};
@@ -101,11 +103,11 @@ static int opt_proc( void *data, const char *arg, int key,
101103
return 1;
102104
case OPT_KEY_HELP:
103105
usage( outargs->argv[0] );
104-
fuse_opt_add_arg( outargs, "-ho" );
106+
cli.help = 1;
105107
return 0;
106108
case OPT_KEY_VERSION:
107109
fprintf( stderr, "fuse-ods2 0.1\n" );
108-
fuse_opt_add_arg( outargs, "--version" );
110+
cli.version = 1;
109111
return 0;
110112
default:
111113
return 1;
@@ -265,6 +267,10 @@ int main( int argc, char *argv[] ) {
265267

266268
if( fuse_opt_parse( &args, &cli, fuse_ods2_opts, opt_proc ) == -1 )
267269
return 1;
270+
if( cli.help || cli.version ) {
271+
fuse_opt_free_args( &args );
272+
return 0;
273+
}
268274

269275
/* Read-only is enforced inside every write op (-EROFS). We do
270276
* NOT inject -oro / -odefault_permissions into the libfuse arg

0 commit comments

Comments
 (0)