{"id":25897245,"url":"https://github.com/sigpwned/just-args-java","last_synced_at":"2025-03-02T23:18:47.086Z","repository":{"id":280065541,"uuid":"912180454","full_name":"sigpwned/just-args-java","owner":"sigpwned","description":"Simple CLI argument parsing library","archived":false,"fork":false,"pushed_at":"2025-03-01T01:36:26.000Z","size":33,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-01T02:26:44.933Z","etag":null,"topics":["args","args-parser","cli","cli-parameters","cli-parser","java","java-8"],"latest_commit_sha":null,"homepage":"https://github.com/sigpwned/just-args-java","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sigpwned.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":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-04T20:41:24.000Z","updated_at":"2025-03-01T01:36:22.000Z","dependencies_parsed_at":"2025-03-01T02:26:52.102Z","dependency_job_id":"ed275d0b-d21f-4afc-9ae9-1239670381c1","html_url":"https://github.com/sigpwned/just-args-java","commit_stats":null,"previous_names":["sigpwned/just-args-java"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sigpwned%2Fjust-args-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sigpwned%2Fjust-args-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sigpwned%2Fjust-args-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sigpwned%2Fjust-args-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sigpwned","download_url":"https://codeload.github.com/sigpwned/just-args-java/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241582852,"owners_count":19985899,"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":["args","args-parser","cli","cli-parameters","cli-parser","java","java-8"],"created_at":"2025-03-02T23:18:46.581Z","updated_at":"2025-03-02T23:18:47.077Z","avatar_url":"https://github.com/sigpwned.png","language":"Java","readme":"# Just Args for Java [![tests](https://github.com/sigpwned/just-args-java/actions/workflows/tests.yml/badge.svg)](https://github.com/sigpwned/just-args-java/actions/workflows/tests.yml) [![Maven Central Version](https://img.shields.io/maven-central/v/com.sigpwned/just-args)](https://central.sonatype.com/artifact/com.sigpwned/just-args) [![javadoc](https://javadoc.io/badge2/com.sigpwned/just-args/javadoc.svg)](https://javadoc.io/doc/com.sigpwned/just-args)\n\nJust Args is a small, simple library for Java that provides command-line argument parsing support and nothing else.\n\n## Goals\n\nJust Args should...\n\n* **Parse arguments**. The library parses valid command-line arguments into a structured and useful model.\n* **Be very small**. The JAR file is currently less than 10KB compressed, under 25KB uncompressed.\n* **Be very simple**. Users only need one method to parse arguments: `JustArgs.parseArgs`.\n* **Be flexible**. Supports options, flags, and positional arguments, as well as advanced configurations.\n* **Be open source**. Released under Unlicense, so you don't have to worry about copyright.\n* **Work out of the box**. Designed to handle common argument parsing use cases with minimal configuration.\n\n## Non-Goals\n\nJust Args should not...\n\n* **Validate command-line usage**. The library is not a strict validator and assumes you know how your CLI should behave.\n* **Provide advanced features**. The library intentionally avoids dependencies, complex argument validation, and advanced frameworks.\n\n## Installation\n\nJust Args is available in Maven Central. You can add it to your project using the following Maven dependency:\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.sigpwned\u003c/groupId\u003e\n    \u003cartifactId\u003ejust-args\u003c/artifactId\u003e\n    \u003cversion\u003e0.0.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nJust Args is a single Java file with no dependencies, so you can also just copy/paste it into your project, in a pinch.\n\n## Quickstart\n\n### Basic Usage\n\nTo parse a list of command-line arguments:\n\n```java\nimport com.sigpwned.just.args.JustArgs;\n\nList\u003cString\u003e args = List.of(\"--xray\", \"value1\", \"-f\", \"positional1\");\n\nMap\u003cCharacter, String\u003e shortOptionNames = Map.of('x', \"xray\");\nMap\u003cString, String\u003e longOptionNames = Map.of(\"xray\", \"xray\");\nMap\u003cCharacter, String\u003e shortPositiveFlagNames = Map.of('f', \"flag\");\nMap\u003cString, String\u003e longPositiveFlagNames = Map.of();\nMap\u003cCharacter, String\u003e shortNegativeFlagNames = Map.of();\nMap\u003cString, String\u003e longNegativeFlagNames = Map.of();\n\nJustArgs.ParsedArgs result = JustArgs.parseArgs(\n    args,\n    shortOptionNames, longOptionNames, \n    shortPositiveFlagNames, longPositiveFlagNames, \n    shortNegativeFlagNames, longNegativeFlagNames);\n\nSystem.out.println(result.getArgs()); // [positional1]\nSystem.out.println(result.getOptions()); // {xray=[value1]}\nSystem.out.println(result.getFlags()); // {flag=[true]}\n```\n\n### Features\n\nJust Args supports:\n\n* **Options**: Arguments with values, e.g., `-k value`, `--key value` or `--key=value`.\n* **Flags**: Boolean arguments, e.g., `-f` or `--flag`.\n* **Short Flag Batches**: Multiple short flags grouped together, e.g., `-abc` is equivialent to `-a -b -c`\n* **Positional Arguments**: Unlabeled arguments.\n* **Separator Token `--`**: Marks all subsequent arguments as positional.\n\n---\n\n## Advanced Usage\n\n### Handling Syntax Errors\n\nJust Args throws a `JustArgs.IllegalSyntaxException` when it encounters invalid syntax. This is a subclass of `IllegalArgumentException` for simplicity.\n\n```java\ntry {\n    JustArgs.parseArgs(...);\n} catch (JustArgs.IllegalSyntaxException e) {\n    System.err.println(\"Syntax error at index \" + e.getIndex() + \": \" + e.getMessage());\n}\n```\n\n### Customizing Argument Names\n\nYou can configure short and long names for options and flags, and assign them to the same logical bucket in the result:\n\n```java\nMap\u003cCharacter, String\u003e shortOptionNames = Map.of('o', \"output\");\nMap\u003cString, String\u003e longOptionNames = Map.of(\"output\", \"output\");\n\nMap\u003cCharacter, String\u003e shortPositiveFlagNames = Map.of('v', \"verbose\");\nMap\u003cString, String\u003e longPositiveFlagNames = Map.of(\"verbose\", \"verbose\");\n```\n\n---\n\n## FAQ\n\n### Why Another Argument Parsing Library?\n\nMost libraries are either too large, too complex, or depend on external frameworks. Just Args is small, simple, and dependency-free—perfect for lightweight projects.\n\n### What About Error Messages?\n\nJust Args focuses on simplicity. Error messages are provided through exceptions, leaving full control to the user.\n\n### Can You Add Feature X?\n\nFeel free to ask, but probably not. Just Args is intentionally minimal. If you need advanced features, consider a more fully-featured library like Apache Commons CLI or Picocli.\n\n---\n\n## A Note on Development\n\nJust Args was built with simplicity and clarity in mind. The library is intentionally small and avoids external dependencies to make it easy to embed in any project.\n\n---\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsigpwned%2Fjust-args-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsigpwned%2Fjust-args-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsigpwned%2Fjust-args-java/lists"}