Documentation
¶
Overview ¶
Package cliopts declares codescan's option surface once, as flags.
Every command that scans - genspec, genspec-wasi - needs the same thing: a flag.FlagSet carrying one flag per knob on codescan.Options, and a way to copy what was parsed onto the options a scan runs with. Written per command, that mapping is partial in a different way each time, and a knob added to the library reaches whichever command somebody remembered.
So it is written here instead, as tables keyed by the field each entry writes to, with one guard (see the package tests) asserting that no value-typed field of the options is left unreachable. A command registers the whole surface and adds only what is its own - where to write, what format, how loud.
Naming ¶
A flag is the kebab-case of the field it writes, without exception: SkipJSONifyInterfaceMethods is -skip-jsonify-interface-methods. Guessing a shorter spelling is how a caller ends up guessing wrong, and no rule can derive that JSONify is one word where HTTPServer is two - which is also why coverage is decided by writing through a setter and seeing what moved, never by mangling a name.
What is not here ¶
Options that are not values: the packages to scan (positional arguments), a filesystem or export data to read (the command opens a path), a specification to merge into (the command loads it), and the diagnostic and provenance callbacks. Those are the command's business; the tests carry the list, with a reason each.
Index ¶
Constants ¶
const DefaultPatterns = "./..."
DefaultPatterns is the pattern a command scans when the caller names nothing.
Variables ¶
var ErrBadFlag = errors.New("bad flag")
ErrBadFlag is a flag whose value is not one of the ones it accepts.
A sentinel rather than a formatted string at each site: a caller - a test, or a command deciding an exit code - can then ask which kind of refusal it met without matching on prose that is free to change.
Functions ¶
func ConfigSchema ¶
ConfigSchema maps each shared option to its address in a configuration file.
func NotConfigurable ¶
NotConfigurable reports the shared options a file may not address, so a command can excuse them in the guard that checks every flag is either addressable or deliberately not.
func Patterns ¶
Patterns is the packages to scan: what the caller named, or everything under the working directory.
Positional rather than a flag, so that `genspec ./api/...` reads the way every other Go command does - which is also why it cannot be a table entry.
Types ¶
type Options ¶
Options is the scan configuration these flags write to.
It is codescan.Options under its internal name - the public type is an alias of this one - so this package depends downward on the scanner rather than back on the root package. A caller holding a *codescan.Options may pass it here unconverted: they are the same type.
type Values ¶
type Values struct {
// contains filtered or unexported fields
}
Values holds a parsed command line, before Values.Apply copies it onto the options.
Lists are held as the raw string the caller typed: splitting at Apply time keeps the three-way cases able to tell an empty list from an absent one.
func Register ¶
Register declares every flag on fs and returns where the parsed values will land.
The whole surface is registered: a command that hides a knob only makes it unreachable, and the caller finds out by meeting "flag provided but not defined" after writing something against a surface that was never there.