Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
github.com/jpvetterli/args
Define and parse command line arguments.
The package keeps simple things simple and makes complicated things possible. For example, this is a simple program argument:
help
and this is something more complicated:
include=[
/home/u649/.db.conf
extractor=[\s*"(\S+)"\s*:\s*"(\S+)"\s*]
keys=[user=usr password=$PASS]
]
With package args, both examples are handled with minimal application logic.
Parameters are defined in one-liners, with synonyms, documentation, and other configuration details. Values are directly taken into simple variables, arrays or slices. Arbitrary types are easily supported like in this example:
a := args.NewParser()
var target time.Time
scanner := func(value string, target interface{}) error {
if s, ok := target.(*time.Time); ok {
if t, err := time.Parse("2006-01-02 15:04:05", value); err == nil {
*s = t
} else {
return err
}
return nil
}
return fmt.Errorf(`time scanner error: "%s", *time.Time target required, not %T`, value, target)
}
// define parameter "time", use custom scanner
a.Def("time", &target).Scan(scanner).Aka("datetime").Doc(`specify time in the format "yyyy-mm-dd hh:mm:ss"`)
// parse an input
a.Parse("time=[2015-06-30 15:32:00]")
// voilà! the value is in the variable
fmt.Println(target.String()) // prints: 2015-06-30 15:32:00 +0000 UTC
More information and examples are available from the package documentation.
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.