{"id":21436749,"url":"https://github.com/modfin/clix","last_synced_at":"2025-03-16T23:23:50.535Z","repository":{"id":262448002,"uuid":"887234232","full_name":"modfin/clix","owner":"modfin","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-07T14:50:57.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-07T15:36:06.860Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/modfin.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-12T11:55:13.000Z","updated_at":"2025-03-07T14:48:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"78c3ac16-4142-4a84-97b5-69dcc3d34d06","html_url":"https://github.com/modfin/clix","commit_stats":null,"previous_names":["modfin/clix"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modfin%2Fclix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modfin%2Fclix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modfin%2Fclix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modfin%2Fclix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/modfin","download_url":"https://codeload.github.com/modfin/clix/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243945787,"owners_count":20372932,"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-11-23T00:14:41.931Z","updated_at":"2025-03-16T23:23:50.529Z","avatar_url":"https://github.com/modfin.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# clix \n\u003e small library meant to turn a command line args into config structs\n\nclix is a helper function for `github.com/urfave/cli`\n\n\n## Installation \n```bash\ngo get github.com/modfin/clix@latest\n```\n\n\n## Usage V2\n\n```go \npackage main\n\nimport (\n\t\"clix\"\n\t\"fmt\"\n\t\"github.com/urfave/cli/v2\"\n\t\"log\"\n\t\"os\"\n)\n\ntype Cfg struct {\n\tStr      string `cli:\"a-str\"`\n\tSubInt   SubInt\n\tSubSlice SubSlice\n}\ntype SubInt struct {\n\tInt int `cli:\"a-int\"`\n}\ntype SubSlice struct {\n\tSubStr   string   `cli:\"a-str\"`\n\tStrSlice []string `cli:\"slice\"`\n}\n\n\nfunc main() {\n\tapp := \u0026cli.App{\n\t\tName: \"test\",\n\t\tFlags: []cli.Flag{\n\t\t\t\u0026cli.StringFlag{\n\t\t\t\tName:    \"a-str\",\n\t\t\t\tEnvVars: []string{\"STR\"},\n\t\t\t},\n\t\t\t\u0026cli.StringFlag{\n\t\t\t\tName: \"a-int\",\n\t\t\t},\n\t\t\t\u0026cli.StringSliceFlag{\n\t\t\t\tName: \"slice\",\n\t\t\t},\n\t\t},\n\t\tAction: func(context *cli.Context) error {\n\n\t\t\t// Running\n\t\t\t// export STR=\"Something strange\"\n\t\t\t// go run example/example.go --a-int 123 --slice=\"in the\" --slice neighborhood\n\n\t\t\t// Takes the context and parses it recursively into a struct.\n\t\t\t// Since github.com/urfave/cli/v2 supports environment variables.\n\t\t\t// We can use both command line args and/or environment variables \n\t\t\t// to parse the input into a struct.\n\t\t\tcfg := clix.Parse[Cfg](context)\n\t\t\tfmt.Printf(\"%+v\", cfg)\n\t\t\t// { Str:Something strange \n\t\t\t//   SubInt: {Int: 123} \n\t\t\t//   SubSlice: {SubStr:Something strange StrSlice:[in the neighborhood]}\n\t\t\t// }\n\t\t\treturn nil\n\t\t},\n\t}\n\tif err := app.Run(os.Args); err != nil {\n\t\tlog.Fatal(err)\n\t}\n}\n\n```\n\n\n## Usage V3\n\n```go \npackage main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"github.com/modfin/clix\"\n\tcli \"github.com/urfave/cli/v3\"\n\t\"log\"\n\t\"os\"\n)\n\ntype Cfg struct {\n\tStr      string `cli:\"a-str\"`\n\tSubInt   SubInt\n\tSubSlice SubSlice\n}\ntype SubInt struct {\n\tInt int `cli:\"a-int\"`\n}\ntype SubSlice struct {\n\tSubStr   string   `cli:\"a-str\"`\n\tStrSlice []string `cli:\"slice\"`\n}\n\nfunc main() {\n\tcmd := \u0026cli.Command{\n\t\tName: \"test\",\n\t\tFlags: []cli.Flag{\n\t\t\t\u0026cli.StringFlag{\n\t\t\t\tName:    \"a-str\",\n\t\t\t\tSources: cli.EnvVars(\"STR\"),\n\t\t\t},\n\t\t\t\u0026cli.StringFlag{\n\t\t\t\tName: \"a-int\",\n\t\t\t},\n\t\t\t\u0026cli.StringSliceFlag{\n\t\t\t\tName: \"slice\",\n\t\t\t},\n\t\t},\n\t\tAction: func(ctx context.Context, cmd *cli.Command) error {\n\n\t\t\t// Running\n\t\t\t// export STR=\"Something strange\"\n\t\t\t// go run example.go --a-int 123 --slice=\"in the\" --slice neighborhood\n\n\t\t\t// Takes the context and parses it recursively into a struct.\n\t\t\t// Since github.com/urfave/cli/v2 supports environment variables.\n\t\t\t// We can use both command line args and/or environment variables\n\t\t\t// to parse the input into a struct.\n\n\t\t\tcfg := clix.Parse[Cfg](clix.V3(cmd))\n\t\t\tfmt.Printf(\"%+v\", cfg)\n\n\t\t\t// { Str:Something strange\n\t\t\t//   SubInt: {Int: 123}\n\t\t\t//   SubSlice: {SubStr:Something strange StrSlice:[in the neighborhood]}\n\t\t\t// }\n\n\t\t\treturn nil\n\t\t},\n\t}\n\tif err := cmd.Run(context.Background(), os.Args); err != nil {\n\t\tlog.Fatal(err)\n\t}\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmodfin%2Fclix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmodfin%2Fclix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmodfin%2Fclix/lists"}