optparse
Rich CLI Option Parser
Functions
| Function | Description |
|---|---|
_opt_copy | |
_opt_streq | |
_opt_strlen | |
opt_new | Create new option parser with max options. |
opt_add | Add an option. short=0 for no short flag. has_val=1 if takes value. |
_opt_find_long | Internal: find option by long name. Returns index or -1. |
_opt_find_short | Internal: find option by short flag. Returns index or -1. |
opt_parse | Parse command-line arguments. argc/argv from os_argv(). Returns 0 on success,… |
opt_get | Get option value. Copies value to out, returns length. 0 if not found. |
opt_has | Check if option was provided. Returns 1 or 0. |
opt_positional | Get positional argument at index. Copies to out, returns length. |
opt_npos | Number of positional arguments found. |
opt_help | Print help message to stdout. |
Details
_opt_copy
fn _opt_copy(dst: &i8, doff: i64, src: &i8, soff: i64, n: i64)_opt_streq
fn _opt_streq(a: &i8, aoff: i64, alen: i64, b: &i8, boff: i64, blen: i64) -> i64_opt_strlen
fn _opt_strlen(s: &i8) -> i64opt_new
fn opt_new(max: i64) -> &i64Create new option parser with max options.
opt_add
fn opt_add(p: &i64, name: &i8, nlen: i64, short: i64, has_val: i64, required: i64, desc: &i8, dlen: i64)Add an option. short=0 for no short flag. has_val=1 if takes value.
_opt_find_long
fn _opt_find_long(p: &i64, name: &i8, nlen: i64) -> i64Internal: find option by long name. Returns index or -1.
_opt_find_short
fn _opt_find_short(p: &i64, ch: i64) -> i64Internal: find option by short flag. Returns index or -1.
opt_parse
fn opt_parse(p: &i64, argc: i64, argv: &i64) -> i64Parse command-line arguments. argc/argv from os_argv(). Returns 0 on success, -1 if required option missing.
opt_get
fn opt_get(p: &i64, name: &i8, nlen: i64, out: &i8) -> i64Get option value. Copies value to out, returns length. 0 if not found.
opt_has
fn opt_has(p: &i64, name: &i8, nlen: i64) -> i64Check if option was provided. Returns 1 or 0.
opt_positional
fn opt_positional(p: &i64, idx: i64, out: &i8) -> i64Get positional argument at index. Copies to out, returns length.
opt_npos
fn opt_npos(p: &i64) -> i64Number of positional arguments found.
opt_help
fn opt_help(p: &i64)Print help message to stdout.