nostril

A C cli tool for creating nostr events
git clone git://jb55.com/nostril
Log | Files | Refs | Submodules | LICENSE

commit f71247279d73083699670a7a7d80e493c1dde157
parent 4e28a847587a2c5a0133065c8a381aeb5675300f
Author: William Casarin <jb55@jb55.com>
Date:   Thu, 17 Nov 2022 17:20:58 -0800

execute subcommands

We will use this for nostril-query

Diffstat:
Mnostril.c | 14++++++++++++++
1 file changed, 14 insertions(+), 0 deletions(-)

diff --git a/nostril.c b/nostril.c @@ -5,6 +5,7 @@ #include <assert.h> #include <errno.h> #include <inttypes.h> +#include <unistd.h> #include "secp256k1.h" #include "secp256k1_ecdh.h" @@ -716,6 +717,17 @@ static int make_encrypted_dm(secp256k1_context *ctx, struct key *key, return 1; } +static void try_subcommand(int argc, const char *argv[]) +{ + static char buf[128] = {0}; + const char *sub = argv[1]; + if (strlen(sub) >= 1 && sub[0] != '-') { + snprintf(buf, sizeof(buf)-1, "nostril-%s", sub); + execvp(buf, (char * const *)argv+1); + } +} + + int main(int argc, const char *argv[]) { struct args args = {0}; @@ -729,6 +741,8 @@ int main(int argc, const char *argv[]) if (!init_secp_context(&ctx)) return 2; + try_subcommand(argc, argv); + if (!parse_args(argc, argv, &args, &ev)) { usage(); return 10;