{"id":18445489,"url":"https://github.com/xxmacmillanxx/vcliargs","last_synced_at":"2026-01-21T09:01:59.581Z","repository":{"id":178072589,"uuid":"661339067","full_name":"xXMacMillanXx/vcliargs","owner":"xXMacMillanXx","description":"A simple V module for handling command line arguments.","archived":false,"fork":false,"pushed_at":"2025-01-27T20:18:31.000Z","size":65,"stargazers_count":1,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-15T05:35:10.761Z","etag":null,"topics":["vlang","vlang-cli","vlang-module","vlang-package"],"latest_commit_sha":null,"homepage":"","language":"V","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xXMacMillanXx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2023-07-02T14:35:53.000Z","updated_at":"2025-01-27T19:47:43.000Z","dependencies_parsed_at":"2024-12-25T01:42:30.337Z","dependency_job_id":"cc2abcf7-c276-4f9e-aed5-4f8da61a17ab","html_url":"https://github.com/xXMacMillanXx/vcliargs","commit_stats":null,"previous_names":["xxmacmillanxx/vcliargs"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/xXMacMillanXx/vcliargs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xXMacMillanXx%2Fvcliargs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xXMacMillanXx%2Fvcliargs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xXMacMillanXx%2Fvcliargs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xXMacMillanXx%2Fvcliargs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xXMacMillanXx","download_url":"https://codeload.github.com/xXMacMillanXx/vcliargs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xXMacMillanXx%2Fvcliargs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28630938,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T04:47:28.174Z","status":"ssl_error","status_checked_at":"2026-01-21T04:47:22.943Z","response_time":86,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["vlang","vlang-cli","vlang-module","vlang-package"],"created_at":"2024-11-06T07:06:05.197Z","updated_at":"2026-01-21T09:01:59.529Z","avatar_url":"https://github.com/xXMacMillanXx.png","language":"V","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vcliargs\nA simple V module for handling command line arguments.\n\n## Usage\n\nThe module has a builder like way to be used:\n\n```v\nmodule main\n\nimport vcliargs\n\nmut prep := vcliargs.Args.new('header', 'description', 'footer')\nprep.add_key(prep.key('path', 'path for input file').alias(['-p', '--path']).multiple(true))\n\nargs := prep.parse()\nprintln('path contains: ' + args['path'])\n\n```\n\nCurrently the following functions can be used:\n\n```v\nmodule main\n\nimport vcliargs\n\nmut prep := vcliargs.Args.new('CLI Tool Header', 'CLI Tool Description', 'CLI Tool Footer')\n\nprep.add_key(prep.key('path', 'Path for input file').alias(['-p', '--path']))\n// .alias sets the parameter specifiers for the cli tool\n\nprep.add_key(prep.key('path', 'Path for input file').alias(['-p', '--path']).default('~/Documents/'))\n// .default sets a default value, which will be used if the parameter wasn't used by the user\n\nprep.add_key(prep.key('path', 'Path for input file').alias(['-p', '--path']).valueless(true))\n// .valueless(true) treats the parameter as a flag, if it was used (e.g., -p) it exist after parse(), otherwise it doesn't\n\nprep.add_key(prep.key('path', 'Path for input file').alias(['-p', '--path']).multiple(true))\n// .multiple(true) lets the parameter accept multiple values (e.g., -p /mnt/ /var/log/)\n\nprep.add_key(prep.key('path', 'Path for input file').alias(['-p', '--path']).options(['ABC', 'XYZ']))\n// .options([...]) specifies values, which will be accepted by the parameter, other values will be rejected\n\nprep.add_key(prep.key('count', 'Count down from the given integer').alias(['-c', '--count']).type_check(vcliargs.ArgTypes.integer))\n// .type_check(ArgTypes) checks if the user input is convertable into the specified data type. Supported types are string, integer (int), float (f64) and boolean (bool).\n// use the vcliargs.convert[T](input string) function to convert strings of the map you receive from parse() or cast it yourself.\n\nprep.add_key(prep.key('count', 'Count down from the given integer').alias(['-c', '--count']).required(true))\n// .required(true) makes it necessary for the parameter to need a value. The value can come from default or user input.\n\nprep.add_key(prep.key('hidden', 'A hidden value to the user, but can be used internally.').default('something'))\n// keys without .alias() won't be accessible by the user, only internally through code.\n\nprep.add_key(prep.key('path', 'Path for input file').alias(['-p', '--path']).default('~/').multiple(true))\n// these function can be used together to have more control over the accepted input.\n\n```\n\n## Documentation\n\n### Args\n\nThe Args struct is used to collect all the needed data to parse user input received through parameters.\n\n#### new()\n\n```v\nfn Args.new(program_name string, description string, epilog_or_footer string) Args\n```\n\nCreates a new Args, with three strings which will be shown in the help. (-h or --help)\n\n#### add_key()\n\n```v\nfn (mut a Args) add_key(k Key)\n```\n\nAdds a Key to Args, which will be used for parsing.\n\n#### key()\n\n```v\nfn (a Args) key(var_name string, description string) Key\n```\n\nCreates a new Key, which will be accessible with the var_name after parsing. The description will be shown in the help. (-h or --help)\n\n### Key\n\nThe Key struct contains all the information needed to parse and check the input of the user.\n\n#### alias()\n\n```v\nfn (k Key) alias(s []string) Key\n```\n\nThis function is necessary for accepting user input, but can be left out for hidden internal usage. Sets the parameter names, which the user uses to specify parameter values.\n\n#### default()\n\n```v\nfn (k Key) default(s string) Key\n```\n\nSets the default value for this parameter, which will be used if the user doesn't change or set the parameter value.\n\n#### valueless()\n\n```v\nfn (k Key) valueless(b bool) Key\n```\n\nSpecifies if this parameter receives a value from the user or if it's used without values. For example '-h' doesn't use a value, it's used like a flag.\n\n#### multiple()\n\n```v\nfn (k Key) multiple(b bool) Key\n```\n\nSpecifies if this parameter expects multiple values. If set to true, one or more values will be accepted for this parameter.\n\n#### options()\n\n```v\nfn (k Key) options(s []string) Key\n```\n\nSets values, which will be accepted as input for this parameter.\n\n#### type_check()\n\n```v\nfn (k Key) type_check(a ArgTypes) Key\n```\n\nSpecifies a type, which will be checked for this parameter. Possible types are: string, int, f64 and bool\n\n#### required()\n\n```v\nfn (k Key) required(b bool) Key\n```\n\nSpecifies if a parameter is required to have a value. This means either a default value or user input is needed.\n\n### ArgTypes\n\n```v\nenum ArgTypes {\n    string\n    float\n    integer\n    boolean\n}\n```\n\nAn enum, which is used for checking types of user input.\n\n\n### convert()\n\n```v\nfn convert[T](s string) ?T\n```\n\nTrys to convert the given string s into the given type T. If type T is not string, f64, int or bool, the function will return none, otherwise it will return the converted value or the default value of the given type.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxxmacmillanxx%2Fvcliargs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxxmacmillanxx%2Fvcliargs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxxmacmillanxx%2Fvcliargs/lists"}