doca-argp

Guides CLI flag registration and lifecycle wiring for DOCA Arg Parser applications.

3.2k|370|Updated Feb 25, 2026
One-click install
npx skills add https://github.com/NVIDIA/skills --skill doca-argp
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: doca-argp
Source: https://github.com/NVIDIA/skills/tree/main/skills/doca-argp
Command: npx skills add https://github.com/NVIDIA/skills --skill doca-argp

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Developers modifying DOCA samples or building DOCA-using applications often break the standard CLI surface, misuse the doca_argp lifecycle, or misdiagnose DOCA_ERROR codes when adding custom flags. This Skill teaches agents the correct register-before-start lifecycle, the six-value parameter type enum, and the Arg Parser error taxonomy so CLI modifications stay consistent with every shipped DOCA sample.

Core Features & Use Cases

  • Lifecycle wiring: Walks the doca_argp_init → register params → doca_argp_start → doca_argp_destroy order, preventing the common BAD_STATE failure from registering params after parsing.
  • Parameter type selection: Chooses from the full public enum (STRING, INT, BOOLEAN, DEVICE, DEVICE_REP, DOUBLE) and explains JSON config as an input surface, not a type.
  • Standard CLI surface preservation: Keeps --device, --representor, --rep-list, --json (-j), and --sdk-log-level working identically across samples, and refuses getopt/argparse rewrites that silently drop JSON-config support.
  • Error diagnosis: Maps DOCA_ERROR_BAD_STATE, INVALID_VALUE, NOT_SUPPORTED, and IO_FAILED from doca_argp_* calls to lifecycle, type-mismatch, unknown-JSON-key, or file-access root causes.
  • Use Case: A developer wants to add --my-flag to the dma_local_copy sample while keeping --device and JSON-config support intact; the Skill routes them to the sample's *_main.c, prescribes a minimum-diff modification, and validates the result via --help, argv, and JSON smoke tests.

Quick Start

Ask your agent to add a custom flag to a shipped DOCA sample using the doca-argp skill while preserving the standard CLI surface.

Frequently Asked Questions about doca-argp

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a custom flag to a DOCA sample?

Register a new doca_argp_param with short name, long name, value callback, description, and type after doca_argp_init but before doca_argp_start in the sample's *_main.c. Reuse the existing Arg Parser wiring rather than replacing it with getopt so the standard CLI surface and JSON-config support stay intact.

Why does doca_argp_register_param return DOCA_ERROR_BAD_STATE?

BAD_STATE means a lifecycle violation: the param was registered after doca_argp_start already parsed argv, doca_argp_start was called twice, or a doca_argp_* call ran after doca_argp_destroy. Move all registration calls between doca_argp_init and doca_argp_start.

What parameter types does DOCA Arg Parser support?

The public enum has six values: DOCA_ARGP_TYPE_STRING, INT, BOOLEAN, DEVICE, DEVICE_REP, and DOUBLE. A JSON config file passed via --json is a separate input surface for those parameters, not a seventh type.

Should I use getopt or doca-argp for my DOCA application's CLI?

Use doca-argp whenever the program calls doca_* symbols, because it preserves the standard --device/--representor/--json/--sdk-log-level surface operators expect across all DOCA samples. A language-native parser is appropriate only for tools that never interact with DOCA.

Why is my JSON config key rejected with DOCA_ERROR_NOT_SUPPORTED?

The Arg Parser uses pedantic parsing: every JSON key must match the long name of a registered parameter. Diff the JSON keys against the registered long names to find the typo or stale key, and validate the file itself with jq before suspecting the library.

How do I check if doca-argp is installed on my DOCA setup?

Run pkg-config --exists doca-argp to confirm presence, then pkg-config --modversion doca-argp for the version. The version should match doca_caps --version; a mismatch indicates a partial install that needs version-layer debugging first.