magus v0.4.3 is out. See what's new
¶ View generated markdown

flags

Parse a script's argv against the flags it declares.

Naming convention: import the module under its bare name (import "flags"), reach members with a backslash, and call methods in camelCase: flags\someMethod.

Methods

parse

Parse argv against the declared flags, returning {values, positionals, unknown}: switches take no value and record "true", valued flags take the next word or an =value suffix, everything after -- is a positional, and every argument that was not declared is returned in unknown rather than guessed at. Errors when a valued flag is given no value.

Signature: flags\parse(argv, switches, valued) -> FlagParse - source

Parameter Type Optional Description
argv []string
switches []string
valued []string

Returns: map[string]any

generatedreference/buzz/flagsmodulestdlibmagusfile
Last updated (9f6be2c6)
Glossary

Magusfile

The magusfile.buzz that declares a project's targets (as export funs) and binds its spells. See targets.

Op

A single tool-native command a target composes (long form: operation); the middle of the work hierarchy (Spell to Op to Target). See operations.

Module

A magus stdlib namespace a magusfile imports for host capabilities: filesystem, exec, vcs, and more. See the module reference.

Buzz

The language magusfiles are written in (the .buzz engine). See engines.

Conventions

This page uses none of the site's convention markers. The full set is on the conventions page.