XU XUv0.16.0

#flag

import: #flag

counts: 1 functions, 41 methods, 3 types, 3 constants, 0 method sets

FlagSet with no globals: define_* + parse + print_defaults.

const EVENT_FLAG

XuAPI
pub const EVENT_FLAG = 0

Purpose

Constant EVENT_FLAG, defining protocol or algorithm parameters.

const EVENT_ARG

XuAPI
pub const EVENT_ARG = 1

Purpose

Constant EVENT_ARG, defining protocol or algorithm parameters.

const EVENT_UNKNOWN

XuAPI
pub const EVENT_UNKNOWN = 2

Purpose

Constant EVENT_UNKNOWN, defining protocol or algorithm parameters.

struct Event

XuAPI
pub struct Event {
    pub kind int
    pub name string
    pub raw string
    pub value string
}

Purpose

Structure encapsulating kind, name, raw, value.

Public fields

kind int
kind tag
name string
name
raw string
field (string)
value string
field (string)

struct Set

XuAPI
pub struct Set {
    pub name string
    pub names []string
    pub kinds []int
    pub bs []bool
    pub ss []string
    pub ins []int
    pub fs []f64
    pub durs []int
    pub usages []string
    pub set_flags []bool
    pub rest []string
    pub parsed bool
    pub alias_keys []string
    pub alias_targets []string
    pub allow_slash_mode bool
    pub sl_flag_idx []int
    pub sl_vals []string
    pub events []Event
    pub unknowns []string
    pub allow_unknown_mode bool
    pub allow_colon_fallback_mode bool
}

Purpose

Structure encapsulating name, names, kinds, bs, ss.

Public fields

name string
name
names []string
field ([]string)
kinds []int
field ([]int)
bs []bool
field ([]bool)
ss []string
field ([]string)
ins []int
field ([]int)
fs []f64
field ([]f64)
durs []int
field ([]int)
usages []string
field ([]string)
set_flags []bool
field ([]bool)
rest []string
field ([]string)
parsed bool
field (bool)
alias_keys []string
field ([]string)
alias_targets []string
field ([]string)
allow_slash_mode bool
field (bool)
sl_flag_idx []int
field ([]int)
sl_vals []string
field ([]string)
events []Event
field ([]Event)
unknowns []string
field ([]string)
allow_unknown_mode bool
field (bool)
allow_colon_fallback_mode bool
field (bool)

new_set

XuAPI
pub fn new_set(name string) Set

Purpose

Construct set.

Parameters

name string
name (string)

Returns

Set — a value of this type

($&Set) allow_slash

XuAPI
pub fn (s $&Set) allow_slash(enable bool)

Purpose

allow_slash enables Windows-style '/' option prefix parsing (e.g. /?, /S).

Parameters

s $&Set
The Set instance used by this call (exclusive borrow).
enable bool
enable (bool)

Returns

This call does not return a value.

($&Set) allow_unknown

XuAPI
pub fn (s $&Set) allow_unknown(enable bool)

Purpose

allow_unknown records unknown flags instead of returning an error.

Parameters

s $&Set
The Set instance used by this call (exclusive borrow).
enable bool
enable (bool)

Returns

This call does not return a value.

($&Set) allow_colon_fallback

XuAPI
pub fn (s $&Set) allow_colon_fallback(enable bool)

Purpose

allow_colon_fallback enables prefix matching across ':' specifiers (e.g. -c:v:0 -> -c:v -> -c).

Parameters

s $&Set
The Set instance used by this call (exclusive borrow).
enable bool
enable (bool)

Returns

This call does not return a value.

($&Set) alias

XuAPI
pub fn (s $&Set) alias(short_name string, canonical_name string)

Purpose

alias registers an alternative option name pointing to an existing canonical flag.

Parameters

s $&Set
The Set instance used by this call (exclusive borrow).
short_name string
short_name (string)
canonical_name string
canonical_name (string)

Returns

This call does not return a value.

($&Set) define_bool

XuAPI
pub fn (s $&Set) define_bool(name string, def bool, usage string)

Purpose

Operation on $&Set: define bool.

Parameters

s $&Set
The Set instance used by this call (exclusive borrow).
name string
name (string)
def bool
default (bool)
usage string
usage text (string)

Returns

This call does not return a value.

($&Set) define_string

XuAPI
pub fn (s $&Set) define_string(name string, def string, usage string)

Purpose

Operation on $&Set: define string.

Parameters

s $&Set
The Set instance used by this call (exclusive borrow).
name string
name (string)
def string
default (string)
usage string
usage text (string)

Returns

This call does not return a value.

($&Set) define_int

XuAPI
pub fn (s $&Set) define_int(name string, def int, usage string)

Purpose

Operation on $&Set: define int.

Parameters

s $&Set
The Set instance used by this call (exclusive borrow).
name string
name (string)
def int
default (int)
usage string
usage text (string)

Returns

This call does not return a value.

($&Set) define_float64

XuAPI
pub fn (s $&Set) define_float64(name string, def f64, usage string)

Purpose

Operation on $&Set: define float64.

Parameters

s $&Set
The Set instance used by this call (exclusive borrow).
name string
name (string)
def f64
default (f64)
usage string
usage text (string)

Returns

This call does not return a value.

($&Set) define_duration

XuAPI
pub fn (s $&Set) define_duration(name string, def int, usage string)

Purpose

Operation on $&Set: define duration.

Parameters

s $&Set
The Set instance used by this call (exclusive borrow).
name string
name (string)
def int
default (int)
usage string
usage text (string)

Returns

This call does not return a value.

($&Set) define_string_list

XuAPI
pub fn (s $&Set) define_string_list(name string, usage string)

Purpose

Operation on $&Set: define string list.

Parameters

s $&Set
The Set instance used by this call (exclusive borrow).
name string
name (string)
usage string
usage text (string)

Returns

This call does not return a value.

($&Set) define_bool_alias

XuAPI
pub fn (s $&Set) define_bool_alias(name string, short_name string, def bool, usage string)

Purpose

Convenience definition methods with an alias

Parameters

s $&Set
The Set instance used by this call (exclusive borrow).
name string
name (string)
short_name string
short_name (string)
def bool
default (bool)
usage string
usage text (string)

Returns

This call does not return a value.

($&Set) define_string_alias

XuAPI
pub fn (s $&Set) define_string_alias(name string, short_name string, def string, usage string)

Purpose

Operation on $&Set: define string alias.

Parameters

s $&Set
The Set instance used by this call (exclusive borrow).
name string
name (string)
short_name string
short_name (string)
def string
default (string)
usage string
usage text (string)

Returns

This call does not return a value.

($&Set) define_int_alias

XuAPI
pub fn (s $&Set) define_int_alias(name string, short_name string, def int, usage string)

Purpose

Operation on $&Set: define int alias.

Parameters

s $&Set
The Set instance used by this call (exclusive borrow).
name string
name (string)
short_name string
short_name (string)
def int
default (int)
usage string
usage text (string)

Returns

This call does not return a value.

($&Set) define_float64_alias

XuAPI
pub fn (s $&Set) define_float64_alias(name string, short_name string, def f64, usage string)

Purpose

Operation on $&Set: define float64 alias.

Parameters

s $&Set
The Set instance used by this call (exclusive borrow).
name string
name (string)
short_name string
short_name (string)
def f64
default (f64)
usage string
usage text (string)

Returns

This call does not return a value.

($&Set) define_string_list_alias

XuAPI
pub fn (s $&Set) define_string_list_alias(name string, short_name string, usage string)

Purpose

Operation on $&Set: define string list alias.

Parameters

s $&Set
The Set instance used by this call (exclusive borrow).
name string
name (string)
short_name string
short_name (string)
usage string
usage text (string)

Returns

This call does not return a value.

(&Set) get_strings

XuAPI
pub fn (s &Set) get_strings(name string) []string

Purpose

Operation on &Set: read strings.

Parameters

s &Set
The Set instance used by this call (borrow).
name string
name (string)

Returns

[]string — slice result

(&Set) unknown_flags

XuAPI
pub fn (s &Set) unknown_flags() []string

Purpose

Operation on &Set: unknown flags.

Parameters

s &Set
The Set instance used by this call (borrow).

Returns

[]string — slice result

(&Set) event_list

XuAPI
pub fn (s &Set) event_list() []Event

Purpose

Operation on &Set: event list.

Parameters

s &Set
The Set instance used by this call (borrow).

Returns

[]Event — slice result

(&Set) is_set

XuAPI
pub fn (s &Set) is_set(name string) bool

Purpose

Operation on &Set: whether it is set.

Parameters

s &Set
The Set instance used by this call (borrow).
name string
name (string)

Returns

bool — true or false

(&Set) get_bool

XuAPI
pub fn (s &Set) get_bool(name string) bool

Purpose

Operation on &Set: read bool.

Parameters

s &Set
The Set instance used by this call (borrow).
name string
name (string)

Returns

bool — true or false

(&Set) get_string

XuAPI
pub fn (s &Set) get_string(name string) string

Purpose

Operation on &Set: read string.

Parameters

s &Set
The Set instance used by this call (borrow).
name string
name (string)

Returns

string — result string

(&Set) get_int

XuAPI
pub fn (s &Set) get_int(name string) int

Purpose

Operation on &Set: read int.

Parameters

s &Set
The Set instance used by this call (borrow).
name string
name (string)

Returns

int — a value of this type

(&Set) get_float64

XuAPI
pub fn (s &Set) get_float64(name string) f64

Purpose

Operation on &Set: read float64.

Parameters

s &Set
The Set instance used by this call (borrow).
name string
name (string)

Returns

f64 — a value of this type

(&Set) get_duration

XuAPI
pub fn (s &Set) get_duration(name string) int

Purpose

Operation on &Set: read duration.

Parameters

s &Set
The Set instance used by this call (borrow).
name string
name (string)

Returns

int — a value of this type

(&Set) get_bool_or

XuAPI
pub fn (s &Set) get_bool_or(name string, def bool) bool

Purpose

Fallback getters: return specified default value when flag was not explicitly provided on CLI

Parameters

s &Set
The Set instance used by this call (borrow).
name string
name (string)
def bool
default (bool)

Returns

bool — true or false

(&Set) get_string_or

XuAPI
pub fn (s &Set) get_string_or(name string, def string) string

Purpose

Operation on &Set: read string or.

Parameters

s &Set
The Set instance used by this call (borrow).
name string
name (string)
def string
default (string)

Returns

string — result string

(&Set) get_int_or

XuAPI
pub fn (s &Set) get_int_or(name string, def int) int

Purpose

Operation on &Set: read int or.

Parameters

s &Set
The Set instance used by this call (borrow).
name string
name (string)
def int
default (int)

Returns

int — a value of this type

(&Set) get_float64_or

XuAPI
pub fn (s &Set) get_float64_or(name string, def f64) f64

Purpose

Operation on &Set: read float64 or.

Parameters

s &Set
The Set instance used by this call (borrow).
name string
name (string)
def f64
default (f64)

Returns

f64 — a value of this type

(&Set) get_duration_or

XuAPI
pub fn (s &Set) get_duration_or(name string, def int) int

Purpose

Operation on &Set: read duration or.

Parameters

s &Set
The Set instance used by this call (borrow).
name string
name (string)
def int
default (int)

Returns

int — a value of this type

(&Set) print_defaults

XuAPI
pub fn (s &Set) print_defaults()

Purpose

Operation on &Set: print defaults.

Parameters

s &Set
The Set instance used by this call (borrow).

Returns

This call does not return a value.

(&Set) args

XuAPI
pub fn (s &Set) args() []string

Purpose

Operation on &Set: return the command-line argument slice.

Parameters

s &Set
The Set instance used by this call (borrow).

Returns

[]string — slice result

($&Set) parse

XuAPI
pub fn (s $&Set) parse(args []string) int

Purpose

parse consumes args ( FlagSet.Parse shape); returns 0 on success. Positional arguments are kept in the set. May >> errors.Error. Throws on failure; handle the error or propagate it to the caller.

Parameters

s $&Set
The Set instance used by this call (exclusive borrow).
args []string
variadic arguments ([]string)

Returns

int — a value of this type

($&Set) parse_from

XuAPI
pub fn (s $&Set) parse_from(args &[]string, start int) int

Purpose

Operation on $&Set: parse as from. Throws on failure; handle the error or propagate it to the caller.

Parameters

s $&Set
The Set instance used by this call (exclusive borrow).
args &[]string
variadic arguments (read-only borrow; caller keeps the original; type &[]string)
start int
start (int)

Returns

int — a value of this type

(&Set) nflag

XuAPI
pub fn (s &Set) nflag() int

Purpose

Execute nflag on &Set.

Parameters

s &Set
The Set instance used by this call (borrow).

Returns

int — a value of this type

($&Set) set

XuAPI
pub fn (s $&Set) set(name string, value string) int

Purpose

Execute set on $&Set. Throws on failure; handle the error or propagate it to the caller.

Parameters

s $&Set
The Set instance used by this call (exclusive borrow).
name string
name (string)
value string
value (string)

Returns

int — a value of this type

(&Set) visit

XuAPI
pub fn (s &Set) visit() []string

Purpose

Execute visit on &Set.

Parameters

s &Set
The Set instance used by this call (borrow).

Returns

[]string — slice result

struct Flag

XuAPI
pub struct Flag {
    pub name string
    pub usage string
    pub is_set bool
    pub found bool
}

Purpose

Structure encapsulating name, usage, is_set, found.

Public fields

name string
name
usage string
usage text
is_set bool
field (bool)
found bool
field (bool)

(&Set) lookup

XuAPI
pub fn (s &Set) lookup(name string) Flag

Purpose

Operation on &Set: look up matching key or item in index or collection.

Parameters

s &Set
The Set instance used by this call (borrow).
name string
name (string)

Returns

Flag — a value of this type

(&Set) narg

XuAPI
pub fn (s &Set) narg() int

Purpose

Execute narg on &Set.

Parameters

s &Set
The Set instance used by this call (borrow).

Returns

int — a value of this type

(&Set) parsed

XuAPI
pub fn (s &Set) parsed() bool

Purpose

Execute parsed on &Set.

Parameters

s &Set
The Set instance used by this call (borrow).

Returns

bool — true or false

(&Set) arg

XuAPI
pub fn (s &Set) arg(i int) string

Purpose

Execute arg on &Set.

Parameters

s &Set
The Set instance used by this call (borrow).
i int
index or integer (int)

Returns

string — result string

(&Set) visit_all

XuAPI
pub fn (s &Set) visit_all() []string

Purpose

Operation on &Set: visit all.

Parameters

s &Set
The Set instance used by this call (borrow).

Returns

[]string — slice result