Skip to content

Conversation

@timandy
Copy link

@timandy timandy commented Mar 11, 2024

Support multiple chars shorthand.
eg:
-ff file
--filefrom file

some commit cherry-picked from #175 .

@CLAassistant
Copy link

CLAassistant commented Mar 11, 2024

CLA assistant check
All committers have signed the CLA.

@brandon1024
Copy link

I'm not sure these changes really fit into the spirit of the pflag library. The changes proposed here deviate from POSIX and introduce ambiguities. If you want something like this, I would almost recommend sticking to the standard flag library which allows you do handle flags like this more easily without deviating from POSIX conventions.

flag.StringVar(&from, "ff", "", "usage")
flag.StringVar(&from, "fromfile", "", "usage")

@timandy
Copy link
Author

timandy commented Dec 1, 2025

go asm use no-standard flag, I want to use this lib resolve asm args, befor pass to it.

.\asm.exe --help
usage: asm [options] file.s ...
Flags:
 -D value
       predefined symbol with optional simple value -D=identifier=value; can be set multiple times
 -I value
       include directory; can be set multiple times
 -S    print assembly and machine code
 -V    print version and exit
 -d value
       enable debugging settings; try -d help
 -debug
       dump instructions as they are parsed
 -dynlink
       support references to Go symbols defined in other shared libraries
 -e    no limit on number of errors reported
 -gensymabis
       write symbol ABI information to output file, don't assemble
 -linkshared
       generate code that will be linked against Go shared libraries
 -o string
       output file; default foo.o for /a/b/c/foo.s as first argument
 -p string
       set expected package import to path (default "<unlinkable>")
 -shared
       generate code that can be linked into a shared library
 -spectre list
       enable spectre mitigations in list (all, ret)
 -trimpath string
       remove prefix from recorded source file paths
 -v    print debug output

@brandon1024
Copy link

All standard go tooling (build, test, asm, etc) use the flag stdlib. This was an explicit design choice by the Go developers, and this will not be changed. If you need go-style flag parsing, use the stdlib. If you want POSIX flags, use pflag.

@brandon1024
Copy link

This might be helpful depending on what you're trying to do:

https://github.com/spf13/pflag?tab=readme-ov-file#supporting-go-flags-when-using-pflag

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants