{"id":22622581,"url":"https://github.com/jonbeebe/bflag","last_synced_at":"2025-03-29T02:42:40.939Z","repository":{"id":57584622,"uuid":"85458747","full_name":"jonbeebe/bflag","owner":"jonbeebe","description":"A simple Go package for building command-line interfaces.","archived":false,"fork":false,"pushed_at":"2017-03-20T00:14:57.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-03T12:50:42.151Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonbeebe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-19T07:35:21.000Z","updated_at":"2017-03-19T07:38:59.000Z","dependencies_parsed_at":"2022-09-13T07:50:26.606Z","dependency_job_id":null,"html_url":"https://github.com/jonbeebe/bflag","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonbeebe%2Fbflag","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonbeebe%2Fbflag/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonbeebe%2Fbflag/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonbeebe%2Fbflag/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonbeebe","download_url":"https://codeload.github.com/jonbeebe/bflag/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246131242,"owners_count":20728299,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-08T23:16:47.203Z","updated_at":"2025-03-29T02:42:40.921Z","avatar_url":"https://github.com/jonbeebe.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bflag [![GoDoc](https://godoc.org/github.com/jonbeebe/bflag?status.png)](https://godoc.org/github.com/jonbeebe/bflag)\n\n**bflag** is a simple [Go](https://golang.org) package for building command-line interfaces. It primarily does two things:\n\n1. Allows you to define valid command-line options for your program.\n2. Parses user-provided options and gives you all the other arguments (minus the options) so your program can react accordingly.\n\n## What about flag?\n\nThere is already a similar official package called [flag](https://golang.org/pkg/flag/) that has many more features than bflag, but it ultimately didn't fit my needs because it only supports single-hyphen (`-flag`) options.\n\n## Example usage\n\n    package main\n\n    import (\n        \"fmt\"\n        \"github.com/jonbeebe/bflag\"\n    )\n\n    func main() {\n        // Define options for our program\n        boolOpt := bflag.DefineBool(\"mybool\", 'b', false)\n        strOpt := bflag.DefineString(\"mystr\", 's', \"Hello world\")\n        intOpt := bflag.DefineInt(\"myint\", 'i', 32)\n        floatOpt := bflag.DefineFloat(\"myfloat\", 'f', 16.5)\n        bflag.Parse()\n\n        // Output invalid arguments (if any were provided)\n        args := bflag.Args()\n        command := args[0]\n        for _, v := range bflag.Invalid() {\n            fmt.Println(\"bflagtest \" + command + \": \" + v)\n        }\n\n        // Print options\n        fmt.Printf(\"Options (%d): \", bflag.NOptions())\n        fmt.Printf(\"--mybool: %t --mystr: %s --myint: %d --myfloat: %.2f\\n\", boolOpt.Value, strOpt.Value, intOpt.Value, floatOpt.Value)\n\n        // Print arguments (bflag doesn't differentiate between commands and arguments)\n        fmt.Printf(\"Arguments (%d): \", bflag.NArgs())\n        for _, v := range args {\n            fmt.Printf(\"%s \", v)\n        }\n        fmt.Print(\"\\n\")\n    }\n\n## TODO\n\n* Handling of `--help` and `--version` options\n* Documentation","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonbeebe%2Fbflag","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonbeebe%2Fbflag","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonbeebe%2Fbflag/lists"}