Categorygithub.com/droundy/goopt
modulepackage
0.0.0-20220217183150-48d6390ad4d1
Repository: https://github.com/droundy/goopt.git
Documentation: pkg.go.dev

# README

goopt

A getopt-like processor of command-line flags. It works much like the "flag" package, only it processes arguments in a way that is compatible with the getopt_long syntax, which is an extension of the syntax recommended by POSIX.

Example program

The example program named example/example.go, is meant to be more useful for someone trying to see how the package works. It comes with a makefile demonstrating how to do some nice tricks, such as enabling bash completion on your flags, and generating man pages and html versions of the man page (see the man page for the example program).

Test suite

The test suite is the file .test, which compiles and verifies the output of the program in the test-program directory, as well as the example program. You can configure git to run the test suite automatically by running the setup-git.sh script.

Documentation

Once the package is installed via goinstall, use the following to view the documentation:

godoc --http=:6060

If you installed it from github, you will want to do this from the source directory:

godoc --http=:6060 --path=.

This will run in the foreground, so do it in a terminal without anything important in it. Then you can go to http://localhost:6060/ and navigate via the package directory to the documentation or the left-hand navigation, depending on if it was goinstalled or run from a git clone.

# Packages

No description provided by the author
No description provided by the author

# Functions

Create a required-argument flag that only accepts the given set of values Parameters: names []string These are the names that are accepted on the command-line for this flag, e.g.
Create a required-argument flag that only accepts the given set of valuesand has a Help() label Parameters: names []string These are the names that are accepted on the command-line for this flag, e.g.
Expand all variables in Vars within the given string.
Create a no-argument flag that is set by either passing one of the "NO" flags or one of the "YES" flags.
Create a required-argument flag that accepts int values Parameters: names []string These are the names that are accepted on the command-line for this flag, e.g.
Create a required-argument flag that accepts int values and has a Help() label Parameters: names []string These are the names that are accepted on the command-line for this flag, e.g.
Add a new flag that does not allow arguments Parameters: names []string These are the names that are accepted on the command-line for this flag, e.g.
Add a new flag that may optionally have an argument Parameters: names []string These are the names that are accepted on the command-line for this flag, e.g.
This parses the command-line arguments.
Add a new flag that requires an argument Parameters: names []string These are the names that are accepted on the command-line for this flag, e.g.
Create a required-argument flag that accepts string values Parameters: names []string These are the names that are accepted on the command-line for this flag, e.g.
Create a required-argument flag that accepts string values but allows more than one to be specified Parameters: names []string These are the names that are accepted on the command-line for this flag, e.g.
Create a required-argument flag that accepts string values and has a Help() label Parameters: names []string These are the names that are accepted on the command-line for this flag, e.g.
Execute the given closure on the name of all known arguments.

# Variables

This is the list of non-flag arguments after processing.
Redefine this to change the author of your program (used in the default man page).
Set the description used in the man page for your program.
Redefine this to change the additional usage of your program (used in the default Usage() and man page).
Override the way help is displayed (not recommended).
Redefine this to force flags to come before all options or be treated as if they were options.
Redefine this to change the suite of your program (e.g.
Redefine this to change the summary of your program (used in the default Usage() and man page).
Override the shortened help for your program (not recommended).
Redefine this function to change the way usage is printed.
Variables for expansion using Expand(), which is automatically called on help text for flags.
Redefine this to change the displayed version of your program (used in the default man page).