Skip to content

off by one #12

@DarVoid

Description

@DarVoid

I created a little project to showcase my problem, I wanted to use your package to check if some flags are being sent and ignored by the tool I was making and got an unexpected result

Image
package main

import (
	"fmt"
	"os"
	"log"
	"github.com/fred1268/go-clap/clap"
)

type exampleStruct struct{
  ExampleValue string `clap:"--sad"`
}

func main(){
	args := os.Args[1:]
	fmt.Println(args)
	app := new(exampleStruct)
	results, err := clap.Parse(args, app)
	if err != nil {
		// results contains a list of arguments in error
		// can be used for user friendly error handling

		log.Fatal(err)
	}
	fmt.Println("has warnings ", results.HasWarnings())
	fmt.Println("has errors ", results.HasErrors())

	fmt.Printf("ignored fields: %v\n", results.Ignored)
	fmt.Printf("missing fields: %v\n", results.Missing)
	fmt.Printf("unex fields: %v\n", results.Unexpected)
	fmt.Printf("duped fields: %v\n", results.Duplicated)
	fmt.Printf("manda fields: %v\n", results.Mandatory)

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions