Skip to content

eloonstra/argparser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

argparser

An opinionated argument parser for Go.

Table Of Contents

Usage

This package allows for understanding the following command line arguments format. command [arguments] [parameters] i.e.: command do --something

Import the package into your project.

import "github.com/eloonstra/argparser"

Grab the arguments from the command line.

args := argparser.Parse()

Now you can check whether an argument is present.

if args.HasArg("foo") {
    // do something
}

You can also check for parameters (including finding out their value) as follows.

if args.HasParam("foo") {
    value, err := args.GetParamValue("foo")
    // do something
}

That's it! All the other stuff is handled for you.

License

MIT