Awesome Go

parseargs-go

CategoryText Processing
SubcategoryParsers/Encoders/Decoders
Stars0

string argument parser that understands quotes and backslashes

About parseargs-go

GoDoc Codeship Codecov Go Report Card

parseargs-go

This is a port of the parserargs.js project to Go.

What about parsing arguments allowing quotes in them? But beware that this library will not parse flags (-- and -), flags will be returned as simple strings.

Installation

go get -u github.com/txgruppi/parseargs-go

Example

package main

import (
  "fmt"
  "log"

  "github.com/txgruppi/parseargs-go"
)

func main() {
  setInRedis := `set name "Put your name here"`
  parsed, err := parseargs.Parse(setInRedis)
  if err != nil {
    log.Fatal(err)
  }
  fmt.Printf("%#v\n", parsed) // []string{"set", "name", "Put your name here"}
}

Tests

go get -u -t github.com/txgruppi/parseargs-go
cd $GOPATH/src/github.com/txgruppi/parseargs-go
go test ./...

License

MIT

Frequently Asked Questions

What is parseargs-go?

parseargs-go is a Text Processing library for the Go programming language. string argument parser that understands quotes and backslashes

How do I install parseargs-go?

Install parseargs-go with the Go module system using `go get nproc/parseargs-go`. Check the repository for the current installation instructions.

What category does parseargs-go belong to?

parseargs-go is listed under Text Processing, specifically Parsers/Encoders/Decoders.

← Back to Parsers/Encoders/Decoders