xflag

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package xflag extends the standard library's flag package to support parsing flags interleaved with positional arguments. By default, Go's flag package stops parsing flags at the first non-flag argument, which is unintuitive for most CLI users. This package provides ParseToEnd as a drop-in replacement that handles flags anywhere in the argument list.

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