{"id":13485477,"url":"https://github.com/airlift/airline","last_synced_at":"2025-05-13T15:59:46.601Z","repository":{"id":4069586,"uuid":"5173953","full_name":"airlift/airline","owner":"airlift","description":"Java annotation-based framework for parsing Git like command line structures","archived":false,"fork":false,"pushed_at":"2022-05-10T16:49:33.000Z","size":287,"stargazers_count":846,"open_issues_count":27,"forks_count":138,"subscribers_count":50,"default_branch":"master","last_synced_at":"2024-10-30T20:44:49.187Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/airlift.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-07-25T02:37:13.000Z","updated_at":"2024-10-23T09:17:45.000Z","dependencies_parsed_at":"2022-08-06T15:00:04.025Z","dependency_job_id":null,"html_url":"https://github.com/airlift/airline","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/airlift%2Fairline","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/airlift%2Fairline/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/airlift%2Fairline/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/airlift%2Fairline/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/airlift","download_url":"https://codeload.github.com/airlift/airline/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245910767,"owners_count":20692497,"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-07-31T18:00:23.970Z","updated_at":"2025-03-27T19:31:13.262Z","avatar_url":"https://github.com/airlift.png","language":"Java","funding_links":[],"categories":["Projects","Java ☕"],"sub_categories":["CLI","Command-line Argument Parsers"],"readme":"# :warning: DEPRECATED :warning:\n\nThis project is no longer maintained. We recommend\n[Airline 2](https://rvesse.github.io/airline/) or\n[Picocli](https://picocli.info/) as a replacement.\n\nAirline\n=======\n\nAirline is a Java annotation-based framework for parsing Git like command line structures.\n\nLatest release is 0.9, available from Maven Central.\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003eio.airlift\u003c/groupId\u003e\n    \u003cartifactId\u003eairline\u003c/artifactId\u003e\n    \u003cversion\u003e0.9\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nHere is a quick example:\n\n```java\npublic class Git\n{\n    public static void main(String[] args)\n    {\n        CliBuilder\u003cRunnable\u003e builder = Cli.\u003cRunnable\u003ebuilder(\"git\")\n                .withDescription(\"the stupid content tracker\")\n                .withDefaultCommand(Help.class)\n                .withCommands(Help.class, Add.class);\n\n        builder.withGroup(\"remote\")\n                .withDescription(\"Manage set of tracked repositories\")\n                .withDefaultCommand(RemoteShow.class)\n                .withCommands(RemoteShow.class, RemoteAdd.class);\n\n        Cli\u003cRunnable\u003e gitParser = builder.build();\n\n        gitParser.parse(args).run();\n    }\n\n    public static class GitCommand implements Runnable\n    {\n        @Option(type = OptionType.GLOBAL, name = \"-v\", description = \"Verbose mode\")\n        public boolean verbose;\n\n        public void run()\n        {\n            System.out.println(getClass().getSimpleName());\n        }\n    }\n\n    @Command(name = \"add\", description = \"Add file contents to the index\")\n    public static class Add extends GitCommand\n    {\n        @Arguments(description = \"Patterns of files to be added\")\n        public List\u003cString\u003e patterns;\n\n        @Option(name = \"-i\", description = \"Add modified contents interactively.\")\n        public boolean interactive;\n    }\n\n    @Command(name = \"show\", description = \"Gives some information about the remote \u003cname\u003e\")\n    public static class RemoteShow extends GitCommand\n    {\n        @Option(name = \"-n\", description = \"Do not query remote heads\")\n        public boolean noQuery;\n\n        @Arguments(description = \"Remote to show\")\n        public String remote;\n    }\n\n    @Command(name = \"add\", description = \"Adds a remote\")\n    public static class RemoteAdd extends GitCommand\n    {\n        @Option(name = \"-t\", description = \"Track only a specific branch\")\n        public String branch;\n\n        @Arguments(description = \"Remote repository to add\")\n        public List\u003cString\u003e remote;\n    }\n}\n```\n\nAssuming you have packaged this as an executable program named 'git', you would be able to execute the following commands:\n\n```shell\n$ git add -p file\n\n$ git remote add origin git@github.com:airlift/airline.git\n\n$ git -v remote show origin\n```\n\n\n\nSingle Command Mode\n===================\n\nAirline can also be used for simple, single-command programs:\n\n```java\n@Command(name = \"ping\", description = \"network test utility\")\npublic class Ping\n{\n    @Inject\n    public HelpOption helpOption;\n\n    @Option(name = {\"-c\", \"--count\"}, description = \"Send count packets\")\n    public int count = 1;\n\n    public static void main(String... args)\n    {\n        Ping ping = SingleCommand.singleCommand(Ping.class).parse(args);\n\n        if (ping.helpOption.showHelpIfRequested()) {\n            return;\n        }\n\n        ping.run();\n    }\n\n    public void run()\n    {\n        System.out.println(\"Ping count: \" + count);\n    }\n}\n```\n\nAssuming you have packaged this as an executable program named 'ping', you would be able to execute the following commands:\n\n```shell\n$ ping\n\n$ ping -c 5\n\n$ ping --help\n```\n\n\n\nHelp System\n===========\n\nAirline contains a fully automated help system, which generates man-page-like documentation driven by the Java\nannotations.\n\nAs you may have noticed in the git code above, we added `Help.class` to the cli.  This command is provided by Airline and works as follows:\n\n```shell\n$ git help\nusage: git [-v] \u003ccommand\u003e [\u003cargs\u003e]\n\nThe most commonly used git commands are:\n    add       Add file contents to the index\n    help      Display help information\n    remote    Manage set of tracked repositories\n\nSee 'git help \u003ccommand\u003e' for more information on a specific command.\n\n\n$ git help git\nNAME\n        git - the stupid content tracker\n\nSYNOPSIS\n        git [-v] \u003ccommand\u003e [\u003cargs\u003e]\n\nOPTIONS\n        -v\n            Verbose mode\n\nCOMMANDS\n        help\n            Display help information\n\n        add\n            Add file contents to the index\n\n        remote show\n            Gives some information about the remote \u003cname\u003e\n\n        remote add\n            Adds a remote\n\n\n\n$ git help add\nNAME\n        git add - Add file contents to the index\n\nSYNOPSIS\n        git [-v] add [-i] [--] [\u003cpatterns\u003e...]\n\nOPTIONS\n        -i\n            Add modified contents interactively.\n\n        -v\n            Verbose mode\n\n        --\n            This option can be used to separate command-line options from the\n            list of argument, (useful when arguments might be mistaken for\n            command-line options\n\n        \u003cpatterns\u003e\n            Patterns of files to be added\n\n\n\n$ git help remote\nNAME\n        git remote - Manage set of tracked repositories\n\nSYNOPSIS\n        git [-v] remote\n        git [-v] remote add [-t \u003cbranch\u003e]\n        git [-v] remote show [-n]\n\nOPTIONS\n        -v\n            Verbose mode\n\nCOMMANDS\n        With no arguments, Gives some information about the remote \u003cname\u003e\n\n        show\n            Gives some information about the remote \u003cname\u003e\n\n            With -n option, Do not query remote heads\n\n        add\n            Adds a remote\n\n            With -t option, Track only a specific branch\n\n\n\n$ git help remote show\nNAME\n        git remote show - Gives some information about the remote \u003cname\u003e\n\nSYNOPSIS\n        git [-v] remote show [-n] [--] [\u003cremote\u003e]\n\nOPTIONS\n        -n\n            Do not query remote heads\n\n        -v\n            Verbose mode\n\n        --\n            This option can be used to separate command-line options from the\n            list of argument, (useful when arguments might be mistaken for\n            command-line options\n\n        \u003cremote\u003e\n            Remote to show\n```\n\nWe have also, add `Help.class` as the default command for git, so if you execute git without any arguments, you will see the following:\n\n```shell\n$ git help\nusage: git [-v] \u003ccommand\u003e [\u003cargs\u003e]\n\nThe most commonly used git commands are:\n    add       Add file contents to the index\n    help      Display help information\n    remote    Manage set of tracked repositories\n\nSee 'git help \u003ccommand\u003e' for more information on a specific command.\n```\n\nFor simple, single-command programs like ping, use the `HelpOption` option as shown in the example above.\n`HelpOption` handles the options `-h` and `--help` and provides the `showHelpIfRequested()` method\nto automatically show the following help output:\n\n```shell\n$ ping -h\nNAME\n        ping - network test utility\n\nSYNOPSIS\n        ping [(-c \u003ccount\u003e | --count \u003ccount\u003e)] [(-h | --help)]\n\nOPTIONS\n        -c \u003ccount\u003e, --count \u003ccount\u003e\n            Send count packets\n\n        -h, --help\n            Display help information\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fairlift%2Fairline","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fairlift%2Fairline","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fairlift%2Fairline/lists"}