akamensky / argparse

Argparse for golang. Just because `flag` sucks
MIT License
611 stars 62 forks source link

[Suggestion] Improve doc of the File type parameter #58

Closed RajaSrinivasan closed 4 years ago

RajaSrinivasan commented 4 years ago

The flag and perm arguments are a bit confusing. Some clarifications and examples might help. On my mac, I find the even when I specify a non existing file I get a non nil File *. I am not sure if this is an issue or a bug in my usage:

pubkeyfile := registercmd.File("p", "public-key-file", os.O_RDONLY, 0, &argparse.Options{Help: "Public Key filename (.pem)"})
parser.Parse(os.Args)
if pubkeyfile == nil {
    log.Println("Invalid public key file")
} else {
    log.Println("Opened public key file")
}

BTW - This is my second project with argparse. Thanks for your efforts.

My first use (one a fork of the other) is at:

https://github.com/RajaSrinivasan/srctrace.git https://github.com/RajaSrinivasan/repotrace.git

They can be viewed as basic and simple applications of argparse.

srini

akamensky commented 4 years ago

... I find the even when I specify a non existing file I get a non nil File *. ...

That sounds like a bug to me unless you specified os.O_CREATE flag, which would create a new file.

Also I don't see anything confusing about flags and permissions, those are exactly same that are used in os package when opening a file.

akamensky commented 4 years ago

Closed as no follow up from OP