{"id":19322723,"url":"https://github.com/picatz/argz","last_synced_at":"2025-10-16T08:21:07.119Z","repository":{"id":89918876,"uuid":"98813048","full_name":"picatz/argz","owner":"picatz","description":"🐉 Command-line application library for Crystal","archived":false,"fork":false,"pushed_at":"2017-07-31T01:05:42.000Z","size":22,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-24T05:45:19.735Z","etag":null,"topics":["command-line","crystal"],"latest_commit_sha":null,"homepage":"","language":"Crystal","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/picatz.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":"2017-07-30T17:17:34.000Z","updated_at":"2025-02-24T05:37:24.000Z","dependencies_parsed_at":"2023-05-30T12:30:13.175Z","dependency_job_id":null,"html_url":"https://github.com/picatz/argz","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/picatz/argz","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/picatz%2Fargz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/picatz%2Fargz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/picatz%2Fargz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/picatz%2Fargz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/picatz","download_url":"https://codeload.github.com/picatz/argz/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/picatz%2Fargz/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279169362,"owners_count":26118420,"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","status":"online","status_checked_at":"2025-10-16T02:00:06.019Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["command-line","crystal"],"created_at":"2024-11-10T01:42:16.240Z","updated_at":"2025-10-16T08:21:07.091Z","avatar_url":"https://github.com/picatz.png","language":"Crystal","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🐲  Argz\n\nCommand-line application library for Crystal.\n\n## Installation\n\nAdd this to your application's `shard.yml`:\n\n```yaml\ndependencies:\n  argz:\n    github: picatz/argz\n```\n\n## Usage\n\n```crystal\nrequire \"argz\"\n```\n\n### Hello World Application\n\n```crystal\nArgz::App.build do \n  name    \"Example Application\"\n  version \"1.0.0\"\n\n  command \"Example\" do\n    long    \"--hello-world\"\n    summary \"Basic hello world command-line option.\"\n\n    action do\n      puts \"Hello World!\"\n    end\n  end\nend\n\nArgz::App.run!\n```\n\n###### Default / Help Output\n\n```shell\nHello World\nVersion: 1.0.0\nUsage: app.cr [Options]\n   --hello-world \tBasic hello world command-line option.\n-h        --help \tPrint out this help menu. \n\n```\n\n#### Each Argument\n\nAccessing each argument that has been passed to the command-line is fairly straight-forward:\n\n```crystal\nArgz::Raw.each do |argument|\n  puts argument # do something with it\nend\n```\n\n#### All Arguments\n\nTo get a big glob of all the possible arguments that were given:\n\n```crystal\nall = Argz::Raw.all\n\nall.class\n# =\u003e Array(String)\n\nall.each do |argument|\n  # do something with the argument\nend\n```\n\n#### Flags\n\nCommand-line arguments are usually specified with flags. Flags start with a \"-\" when passed into the application. Where? At the command-line, naturally. However, \n\n`Argz::Raw.add(flag_or_flags)` Allows us to append arguments to simulate if the arguments were passed to the command-line.\n\n`Argz::Raw.is_flag?(flag)` Will check if a given flag has been passed into the command-line.\n\n`Argz::Raw.is_flag_like?(flag)` Will check if a given string could pass for the flag, but won't check if it actually has been passed as a command-line argument.\n\n```crystal\n# Add raw command-line arguments to ARGV\nArgz::Raw.add([\"-key\", \"value\"]\n\n# Check if a given string is a given command-line flag.\nArgz::Raw.is_flag?(\"-key\")\n# =\u003e true\n\n# This flag hasn't been added as a command-line argument.\nArgz::Raw.is_flag?(\"-nope\")\n# =\u003e false\n\n# Check if a given string is flag-like.\nArgz::Raw.is_flag_like?(\"-nope\")\n# =\u003e true\n```\n\n#### Arguments\n\nArguments for flags exist, but sometimes they don't! How do you work with them?\n\n`Argz::Raw.arguments_to(flag)` will return an array with arguments for that flag if they exist.\n\n`Argz::Raw.arguments_to?(flag)` will return a boolean; true if the flag has arguments, and false if doesn't.\n\n```crystal\nArgz::Raw.add(\"-example\", \"-example2\", \"a\", \"b\", \"c\")\n\n# No arguments given for this flag.\nArgz::Raw.arguments_to?(\"-example\")\n# =\u003e false\nArgz::Raw.arguments_to(\"-example\")\n# =\u003e []\n\n# Arguments given for this flag.\nArgz::Raw.arguments_to?(\"-example2\")\n# =\u003e true\nArgz::Raw.arguments_to(\"-example2\")\n# =\u003e [\"a\", \"b\", \"c\"]\n```\n\n## Contributors\n\n- [picat](https://github.com/picatz) Kent Gruber - creator, maintainer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpicatz%2Fargz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpicatz%2Fargz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpicatz%2Fargz/lists"}