ascii-chat
Binary v0.16.114-28-gf5913657f
Library lib/v0.3.2-3302-gf5913657f
Video chat in your terminal
Loading...
Searching...
No Matches
positional_arg_descriptor_t Struct Reference

Describes one non-option command-line argument and how the parser consumes it. More...

#include <include/ascii-chat/options/builder.h>

Data Fields

const char * name
 Name for help text (e.g., "address", "bind-addr").
const char * help_text
 Description for usage message.
bool required
 If true, this positional arg must be provided.
const char * section_heading
const char ** examples
 Array of example strings with descriptions.
size_t num_examples
 Number of examples.
int(* parse_fn )(const char *arg, void *config, char **remaining, int num_remaining, char **error_msg)
option_mode_bitmask_t mode_bitmask
 Which modes this positional arg applies to.

Detailed Description

Describes one non-option command-line argument and how the parser consumes it.

Describes a positional (non-option) argument parsed after getopt processing. These are arguments that don't start with '-' or '–'.

Examples:

  • Client: "ascii-chat client [address][:port]" - single positional arg with complex parsing
  • Server: "ascii-chat server [addr1] [addr2]" - 0-2 positional args with validation

The parse_fn receives:

  • arg: The positional argument string
  • config: Pointer to full options struct (can modify multiple fields)
  • remaining: Remaining unparsed positional args (for multi-arg parsing)
  • num_remaining: Count of remaining args
  • error_msg: Set on failure (caller will free)

Returns true on success, false on error. The strings and examples are borrowed from the configuration that owns them.

Definition at line 407 of file builder.h.

Field Documentation

◆ examples

const char** positional_arg_descriptor_t::examples

Array of example strings with descriptions.

Definition at line 415 of file builder.h.

Referenced by manpage_content_generate_positional().

◆ help_text

const char* positional_arg_descriptor_t::help_text

Description for usage message.

Definition at line 409 of file builder.h.

Referenced by manpage_content_generate_positional().

◆ mode_bitmask

option_mode_bitmask_t positional_arg_descriptor_t::mode_bitmask

Which modes this positional arg applies to.

Definition at line 433 of file builder.h.

◆ name

const char* positional_arg_descriptor_t::name

Name for help text (e.g., "address", "bind-addr").

Definition at line 408 of file builder.h.

Referenced by manpage_content_generate_positional().

◆ num_examples

size_t positional_arg_descriptor_t::num_examples

Number of examples.

Definition at line 416 of file builder.h.

Referenced by manpage_content_generate_positional().

◆ parse_fn

int(* positional_arg_descriptor_t::parse_fn) (const char *arg, void *config, char **remaining, int num_remaining, char **error_msg)

Custom parser function

Parameters
argCurrent positional argument string
configPointer to options struct (can modify any field)
remainingRemaining positional args (or NULL if last)
num_remainingCount of remaining args
error_msgSet error message on failure (will be freed by caller)
Returns
Number of args consumed (usually 1), or -1 on error

Definition at line 428 of file builder.h.

◆ required

bool positional_arg_descriptor_t::required

If true, this positional arg must be provided.

Definition at line 410 of file builder.h.

◆ section_heading

const char* positional_arg_descriptor_t::section_heading

Section heading for examples (e.g., "ADDRESS FORMATS")

Definition at line 413 of file builder.h.


The documentation for this struct was generated from the following file: