{"id":4199072,"name":"github.com/jba/cli","ecosystem":"go","description":"Package cli helps to build command-line programs with multiple commands.\nA command is created by defining a struct with a Run method. The exported\nfields of the struct are populated with the flags and command-line arguments\npassed to on the command line, as determined by struct tags. For example,\nhere is a struct that could be used for a \"compare\" command that takes\ntwo files and a \"-v\" flag:\n\nThe command's logic is provided in a Run method:\n\nBefore the Run method is called, the command line flags and arguments are parsed\nand assigned to the fields of the receiver struct.\n\nAll commands must be registered, usually at program startup. Begin with a\ntop-level command representing the program itself. Typically no behavior is\nassociated with the top-level command, so the line\n\nsuffices. The top command uses the default flag set of the standard library's\nflag package, so global flags can be defined as usual. The value of top is a\n*cli.Command.\n\nSub-commands are configured by registering a Command struct with an existing\nCommand. Given the compare struct and the top variable shown above, we can\nregister a compare command with\n\nor more succinctly,\n\nThat code can be put in an init method or at the start of main.\n\nThe Top function takes a Command just like the RegisterCommand function, so you\ncan provide behavior for the top-level command by defining a struct with a Run\nmethod, constructing a Command with it, and passing it to Top.\n\nThe struct associated with a command completely describes the command's flags\nand positional arguments. Each exported field can have a struct tag with a \"cli\"\nkey that provides the usage documentation for the argument or flag as well as\nsome options. An exported field without a tag is treated as a positional\nargument with no documentation. Unexported fields are ignored.\n\nA field's type can be any string, bool, integer, floating point or duration\ntype, or a slice of one of those types. If the slice is used for a flag, the\nflag's value is split on commas to populate the slice. Otherwise, the slice\nfield must represent the last positional argument, and its value is taken from\nthe remaining command-line arguments.\n\nThe tag syntax is a comma-separated lists of key=value pairs. The keys are:\n\nFor example, the field and struct tag\n\nwill display the argument as ENV in documentation along with the string\n\"development environment\", and will check that the value on the command line is\neither \"dev\" or \"prod\".\n\nSee the package examples for more.\n\nThe Go flag package provides control over the word printed as the flag's value in documentation,\nby looking for backticks in the usage string. To use this feature, enclose the struct tag\nin double quotes instead of backticks. As a convenience, this package can interpret\nbare struct tags that don't have the usual 'key:\"value\"' format, which makes this cleaner:\n\nOnce the top-level command has been created and all sub-commands have been\nregistered, call the Main method to invoke the appropriate command and get back\nan exit code. If the other work has been done with a global \"top\" variable and\ninit functions, then the entire main function can be\n\nFor more control, you can call Command.Run with a context and a slice of arguments,\nand handle the error yourself.\n\nShell completion for common shells is supported with the\ngithub.com/posener/complete/v2 package. Completion logic is automatically\ninvoked if your program calls Command.Main. To install completion for a program,\nrun it with the COMP_INSTALL environment variable set to 1.","homepage":"https://github.com/jba/cli","licenses":"MIT","normalized_licenses":["MIT"],"repository_url":"https://github.com/jba/cli","keywords_array":[],"namespace":"github.com/jba","versions_count":6,"first_release_published_at":"2021-12-28T17:46:25.000Z","latest_release_published_at":"2022-10-16T13:36:39.000Z","latest_release_number":"v0.6.0","last_synced_at":"2026-05-13T17:02:33.816Z","created_at":"2022-04-12T20:27:54.182Z","updated_at":"2026-05-13T17:02:33.817Z","registry_url":"https://pkg.go.dev/github.com/jba/cli","install_command":"go get github.com/jba/cli","documentation_url":"https://pkg.go.dev/github.com/jba/cli#section-documentation","metadata":{},"repo_metadata":{"uuid":"441494602","full_name":"jba/cli","owner":"jba","description":"command-line support","archived":false,"fork":false,"pushed_at":"2022-10-16T13:37:37.000Z","size":61,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2023-03-07T15:37:14.320Z","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,"logo_url":null,"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":"2021-12-24T15:07:22.000Z","updated_at":"2021-12-30T17:58:27.000Z","dependencies_parsed_at":"2022-08-30T05:52:07.394Z","dependency_job_id":null,"html_url":"https://github.com/jba/cli","commit_stats":null,"repository_url":"http://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jba%2Fcli","tags_url":"http://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jba%2Fcli/tags","manifests_url":"http://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jba%2Fcli/manifests","owner_url":"http://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jba","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":108921946,"host_url":"http://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"http://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"http://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names"}},"repo_metadata_updated_at":"2023-03-21T19:49:50.044Z","dependent_packages_count":1,"downloads":null,"downloads_period":null,"dependent_repos_count":1,"rankings":{"downloads":null,"dependent_repos_count":4.707975409926032,"dependent_packages_count":5.81315175819428,"stargazers_count":25.349839503018302,"forks_count":18.874807547049322,"docker_downloads_count":null,"average":13.686443554546983},"purl":"pkg:golang/github.com/jba/cli","advisories":[],"docker_usage_url":"https://docker.ecosyste.ms/usage/go/github.com/jba/cli","docker_dependents_count":null,"docker_downloads_count":null,"usage_url":"https://repos.ecosyste.ms/usage/go/github.com/jba/cli","dependent_repositories_url":"https://repos.ecosyste.ms/api/v1/usage/go/github.com/jba/cli/dependencies","status":null,"funding_links":[],"critical":null,"issue_metadata":{"last_synced_at":"2023-05-19T01:49:00.701Z","issues_count":1,"pull_requests_count":0,"avg_time_to_close_issue":null,"avg_time_to_close_pull_request":null,"issues_closed_count":0,"pull_requests_closed_count":0,"pull_request_authors_count":0,"issue_authors_count":1,"avg_comments_per_issue":0.0,"avg_comments_per_pull_request":null,"merged_pull_requests_count":0,"bot_issues_count":0,"bot_pull_requests_count":0,"past_year_issues_count":1,"past_year_pull_requests_count":0,"past_year_avg_time_to_close_issue":null,"past_year_avg_time_to_close_pull_request":null,"past_year_issues_closed_count":0,"past_year_pull_requests_closed_count":0,"past_year_pull_request_authors_count":0,"past_year_issue_authors_count":1,"past_year_avg_comments_per_issue":0.0,"past_year_avg_comments_per_pull_request":null,"past_year_bot_issues_count":0,"past_year_bot_pull_requests_count":0,"past_year_merged_pull_requests_count":0},"versions_url":"https://packages.ecosyste.ms/api/v1/registries/proxy.golang.org/packages/github.com%2Fjba%2Fcli/versions","version_numbers_url":"https://packages.ecosyste.ms/api/v1/registries/proxy.golang.org/packages/github.com%2Fjba%2Fcli/version_numbers","latest_version_url":"https://packages.ecosyste.ms/api/v1/registries/proxy.golang.org/packages/github.com%2Fjba%2Fcli/latest_version","dependent_packages_url":"https://packages.ecosyste.ms/api/v1/registries/proxy.golang.org/packages/github.com%2Fjba%2Fcli/dependent_packages","related_packages_url":"https://packages.ecosyste.ms/api/v1/registries/proxy.golang.org/packages/github.com%2Fjba%2Fcli/related_packages","codemeta_url":"https://packages.ecosyste.ms/api/v1/registries/proxy.golang.org/packages/github.com%2Fjba%2Fcli/codemeta","maintainers":[]}