summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2025-05-29 02:04:56 +0000
committermidipix <writeonce@midipix.org>2025-05-29 03:43:47 +0000
commit51125f500691073e197b4272a682956e7e1b0f20 (patch)
tree0e5ae8f67a6528275c9beeaa9e1842793bf4c296 /src
parent59b920bb87eab928e77b5227a1ed9023292a7552 (diff)
downloadperk-51125f500691073e197b4272a682956e7e1b0f20.tar.bz2
perk-51125f500691073e197b4272a682956e7e1b0f20.tar.xz
driver api: refined the logic for display utility usage information.
Diffstat (limited to 'src')
-rw-r--r--src/driver/pe_amain.c2
-rw-r--r--src/driver/pe_driver_ctx.c25
2 files changed, 17 insertions, 10 deletions
diff --git a/src/driver/pe_amain.c b/src/driver/pe_amain.c
index 1804246..8a5724a 100644
--- a/src/driver/pe_amain.c
+++ b/src/driver/pe_amain.c
@@ -13,7 +13,7 @@
#ifndef PERK_DRIVER_FLAGS
#define PERK_DRIVER_FLAGS PERK_DRIVER_VERBOSITY_ERRORS \
- | PERK_DRIVER_VERBOSITY_USAGE
+ | PERK_DRIVER_VERBOSITY_UTILITY
#endif
static const char vermsg[] = "%s%s%s (git://midipix.org/perk): "
diff --git a/src/driver/pe_driver_ctx.c b/src/driver/pe_driver_ctx.c
index 04483eb..c7cd146 100644
--- a/src/driver/pe_driver_ctx.c
+++ b/src/driver/pe_driver_ctx.c
@@ -169,7 +169,6 @@ static int pe_cctx_update(
const char * program,
const struct argv_option ** optv,
struct argv_meta * meta,
- uint32_t flags,
const struct pe_fd_ctx * fdctx,
struct pe_common_ctx * cctx,
size_t * nunits)
@@ -184,11 +183,10 @@ static int pe_cctx_update(
if (entry->fopt) {
switch (entry->tag) {
case TAG_HELP:
- if (flags & PERK_DRIVER_VERBOSITY_USAGE)
- return pe_driver_usage(
- fdctx->fdout,
- program,entry->arg,
- optv,0,cctx->cmd);
+ return pe_driver_usage(
+ fdctx->fdout,
+ program,entry->arg,
+ optv,0,cctx->cmd);
break;
case TAG_CMD:
@@ -342,7 +340,7 @@ int pe_get_driver_ctx(
/* missing arguments? */
argv_optv_init(perk_cmd_options[cctx.cmd],optv);
- if (!argv[1] && (flags & PERK_DRIVER_VERBOSITY_USAGE))
+ if (!argv[1] && (flags & PERK_DRIVER_VERBOSITY_UTILITY))
return pe_driver_usage(
fdctx->fderr,
program,0,
@@ -400,7 +398,7 @@ int pe_get_driver_ctx(
return -1;
if (pe_cctx_update(
- program,optv,meta,flags,
+ program,optv,meta,
fdctx,&cctx,&nunits)) {
argv_free(meta);
return -1;
@@ -429,12 +427,21 @@ int pe_get_driver_ctx(
return -1;
if (pe_cctx_update(
- program,optv,meta,flags,
+ program,optv,meta,
fdctx,&cctx,&nunits)) {
argv_free(meta);
return -1;
}
+ /* utility mode and no action to take? */
+ if (cctx.drvflags & PERK_DRIVER_VERBOSITY_UTILITY)
+ if (!nunits && !(cctx.drvflags & PERK_DRIVER_VERSION))
+ return pe_driver_usage(
+ fdctx->fdout,
+ program,0,
+ optv,meta,cctx.cmd);
+
+ /* context allocation */
if (!(ctx = pe_driver_ctx_alloc(meta,fdctx,&cctx,nunits)))
return pe_get_driver_ctx_fail(meta);