From 88b2201487a0f76a7f4d7a620a6a9af55e29a53c Mon Sep 17 00:00:00 2001 From: Shirong Lu <73147033+happysnaker@users.noreply.github.com> Date: Fri, 3 Jul 2026 21:27:57 +0800 Subject: [PATCH] feat: add package-level SortFlags variable (fixes #382) --- flag.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/flag.go b/flag.go index ced8440a..8abe67ab 100644 --- a/flag.go +++ b/flag.go @@ -1375,6 +1375,10 @@ func Parsed() bool { return CommandLine.Parsed() } +// SortFlags is the package-level convenience alias for CommandLine.SortFlags. +// Set SortFlags to false to print flags in the order they were added. +var SortFlags = &CommandLine.SortFlags + // CommandLine is the default set of command-line flags, parsed from os.Args. var CommandLine = NewFlagSet(os.Args[0], ExitOnError)