xflag

package
v0.0.0-...-f7b2ef8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 1 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

xflag

xflag.ParseToEnd is a drop-in replacement for flag.FlagSet.Parse that keeps parsing after the first positional argument.

if err := xflag.ParseToEnd(flags, os.Args[1:]); err != nil {
	return err
}

This lets both forms work:

todo add --verbose buy-milk
todo add buy-milk --verbose

As with the standard library, -- stops flag parsing and leaves everything after it as positional arguments.

Documentation

Overview

Package xflag parses flags interspersed with positional arguments.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseToEnd

func ParseToEnd(f *flag.FlagSet, arguments []string) error

ParseToEnd is a drop-in replacement for flag.Parse. It improves upon the standard behavior by parsing flags even when they are interspersed with positional arguments. This overcomes Go's default limitation of stopping flag parsing upon encountering the first positional argument. For more details, see:

This is a bit unfortunate, but most users nowadays consuming CLI tools expect this behavior.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL