ZARGS(3)
๐ zargs โ bestie, we're parsing argv ๐
okay so. this is the manual page for zargs, a little class from the CZMQ Manual (CZMQ = the high-level C binding for 0MQ, iykyk). it's literally here to help you parse command line arguments in a platform independent way. no cap. let's get into it ๐
โจ NAME โจ
zargs โ Class for Platform independent command line argument parsing helpers
๐ฆ SYNOPSIS ๐ฆ
โ ๏ธ bestie LISTEN. This is a draft class, and it may change without notice. It is disabled in stable builds by default. If you use this in applications, please ask for it to be pushed to stable state. Use --enable-drafts to enable. ๐ซถ
// This is a draft class, and may change without notice. It is disabled in
// stable builds by default. If you use this in applications, please ask
// for it to be pushed to stable state. Use --enable-drafts to enable.
#ifdef CZMQ_BUILD_DRAFT_API
// *** Draft method, for development use, may change without warning ***
// Create a new zargs from command line arguments.
CZMQ_EXPORT zargs_t *
zargs_new (int argc, char **argv);
// *** Draft method, for development use, may change without warning ***
// Destroy zargs instance.
CZMQ_EXPORT void
zargs_destroy (zargs_t **self_p);
// *** Draft method, for development use, may change without warning ***
// Return program name (argv[0])
CZMQ_EXPORT const char *
zargs_progname (zargs_t *self);
// *** Draft method, for development use, may change without warning ***
// Return number of positional arguments
CZMQ_EXPORT size_t
zargs_arguments (zargs_t *self);
// *** Draft method, for development use, may change without warning ***
// Return first positional argument or NULL
CZMQ_EXPORT const char *
zargs_first (zargs_t *self);
// *** Draft method, for development use, may change without warning ***
// Return next positional argument or NULL
CZMQ_EXPORT const char *
zargs_next (zargs_t *self);
// *** Draft method, for development use, may change without warning ***
// Return first named parameter value, or NULL if there are no named
// parameters, or value for which zargs_param_empty (arg) returns true.
CZMQ_EXPORT const char *
zargs_param_first (zargs_t *self);
// *** Draft method, for development use, may change without warning ***
// Return next named parameter value, or NULL if there are no named
// parameters, or value for which zargs_param_empty (arg) returns true.
CZMQ_EXPORT const char *
zargs_param_next (zargs_t *self);
// *** Draft method, for development use, may change without warning ***
// Return current parameter name, or NULL if there are no named parameters.
CZMQ_EXPORT const char *
zargs_param_name (zargs_t *self);
// *** Draft method, for development use, may change without warning ***
// Return value of named parameter or NULL is it has no value (or was not specified)
CZMQ_EXPORT const char *
zargs_get (zargs_t *self, const char *name);
// *** Draft method, for development use, may change without warning ***
// Return value of one of parameter(s) or NULL is it has no value (or was not specified)
CZMQ_EXPORT const char *
zargs_getx (zargs_t *self, const char *name, ...);
// *** Draft method, for development use, may change without warning ***
// Returns true if named parameter was specified on command line
CZMQ_EXPORT bool
zargs_has (zargs_t *self, const char *name);
// *** Draft method, for development use, may change without warning ***
// Returns true if named parameter(s) was specified on command line
CZMQ_EXPORT bool
zargs_hasx (zargs_t *self, const char *name, ...);
// *** Draft method, for development use, may change without warning ***
// Print an instance of zargs.
CZMQ_EXPORT void
zargs_print (zargs_t *self);
// *** Draft method, for development use, may change without warning ***
// Self test of this class.
CZMQ_EXPORT void
zargs_test (bool verbose);
#endif // CZMQ_BUILD_DRAFT_API
also, note for whoever's maintaining this: Please add '@interface' section in './../src/zargs.c'. ๐
๐ธ DESCRIPTION ๐ธ
zargs โ Platform independent command line argument parsing helpers
Platform independent command line argument parsing helpers
so here's the tea. There are two kind of elements provided by this class:
foo --named-parameter --parameter with_value positional arguments -a gain-parameter
zargs keeps poision only for arguments โ parameters are to be accessed like hash. ๐
๐ It DOES:
- provide easy to use CLASS compatible API for accessing argv
- is platform independent
- provide getopt_long style โ argument, which delimits parameters from arguments
- makes parameters positon independent
๐ It does NOT:
- change argv
- provide a "declarative" way to define command line interface
๐ฎ In future it SHALL:
- hide several formats of command line to one (
-Idir,--include=dir,--include dirare the same from API pov)
also, another lil note for the source file: Please add @discuss section in ./../src/zargs.c. ๐
โจ EXAMPLE โจ
From zargs_test method. no fr, this is the real code, straight from the test, main character energy only:
// Simple create/destroy test
char *argv1[] = {"progname", "--named1", "-n1", "val1", "positional1", "--with", "value", "--with2=value2", "-W3value3", "--", "--thisis", "considered", "positional", NULL};
zargs_t *self = zargs_new (13, argv1);
assert (self);
assert (streq (zargs_progname (self), "progname"));
assert (streq (zargs_first (self), "positional1"));
assert (streq (zargs_next (self), "--thisis"));
assert (streq (zargs_next (self), "considered"));
assert (streq (zargs_next (self), "positional"));
assert (!zargs_next (self));
assert (zargs_has (self, "--named1"));
assert (zargs_has (self, "-n1"));
assert (!zargs_has (self, "--not at all"));
assert (!(zargs_get (self, "--named1")));
assert (streq (zargs_get (self, "-n1"), "val1"));
// common usages - test for -h/--help
bool has_help = zargs_hasx (self, "--help", "-h", NULL);
assert (!has_help);
zargs_destroy (&self);
๐ซถ AUTHORS ๐ซถ
The czmq manual was written by the authors in the AUTHORS file.
๐ RESOURCES ๐
Main web site:
Report bugs to the email <zeromq-dev@lists.zeromq.org[1]> ๐
๐ COPYRIGHT ๐
Copyright (c) the Contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org. This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. LICENSE included with the czmq distribution.
๐ NOTES ๐
zeromq-dev@lists.zeromq.orgโmailto:zeromq-dev@lists.zeromq.org
and that's the whole page bestie, you ate that ๐ โจ this was CZMQ 4.2.1, dated 01/16/2026, and yes this is still ZARGS(3) โ go parse some args, you got this ๐ฆ๐
๐ฆ where this page comes from
- fedora 44: czmq-devel 4.2.1-24.fc44 ยท MPL-2.0
- fedora 44: czmq-devel 4.2.1-24.fc44 ยท MPL-2.0
- ubuntu resolute: libczmq-dev 4.2.1-3build1 ยท MPL-2.0
- ubuntu stonking: libczmq-dev 4.2.1-3build1 ยท MPL-2.0
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms