{
    "href": "/post/2023/05/25/autoshell-10-released/",
    "relId": "2023/05/25/autoshell-10-released",
    "title": "AutoShell 1.0 Released",
    "author": "pmjones",
    "tags": [
        {
            "href": "/tag/programming/",
            "relId": "programming",
            "title": "Programming",
            "author": null,
            "created": null,
            "updated": [],
            "markup": "markdown"
        },
        {
            "href": "/tag/php/",
            "relId": "php",
            "title": "PHP",
            "author": null,
            "created": null,
            "updated": [],
            "markup": "markdown"
        },
        {
            "href": "/tag/autoshell/",
            "relId": "autoshell",
            "title": "Autoshell",
            "author": null,
            "created": "2023-05-25 13:15:43 UTC",
            "updated": [
                "2023-05-25 13:15:43 UTC"
            ],
            "markup": "markdown"
        }
    ],
    "created": "2023-05-25 13:15:43 UTC",
    "updated": [
        "2023-05-25 13:15:43 UTC",
        "2023-05-25 13:36:19 UTC",
        "2023-05-27 14:05:28 UTC"
    ],
    "markup": "markdown",
    "html": "<p>I am proud to announce the first release of <a href=\"https://packagist.org/packages/pmjones/auto-shell\">AutoShell</a>, a library for building CLI commands in PHP 8.1 and up.</p>\n<p>Just as with <a href=\"https://github.com/pmjones/AutoRoute\">AutoRoute</a> for web routing, AutoShell automatically maps CLI command names to PHP command classes in a specified namespace. For example, given a namespace of <code>Project\\Cli\\Command</code>, the CLI command name <code>create-article</code> automatically maps to the <code>Project\\Cli\\Command\\CreateArticle</code> command class.</p>\n<p>AutoShell is low-maintenance. Merely adding a class to your source code, in the recognized namespace and with the recognized main method name, automatically makes it available as a command.</p>\n<p>AutoShell will automatically map command-line arguments to the command class main method parameters. For example, given this command class ...</p>\n<pre><code class=\"language-php\">&lt;?php\nnamespace Project\\Cli\\Command;\n\nuse AutoShell\\Help;\n\n#[Help(\"Says hello to a _name_ of your choice.\")]\nclass Hello\n{\n    public function __invoke(\n\n        #[Help(\"The _name_ to say hello to.\")]\n        string $name\n\n    ) : int\n    {\n        echo \"Hello {$name}\" . PHP_EOL;\n        return 0;\n    }\n}\n</code></pre>\n<p>... AutoShell will recognize <code>php bin/console.php hello world</code>  and output <code>Hello world</code>.</p>\n<p>And as you can see, help is defined via attributes. Options are easy to define, too -- as is combining common option sets with command-specific ones.</p>\n<p>There's a lot more to <a href=\"https://packagist.org/packages/pmjones/auto-shell\">AutoShell</a>; take a look at the <a href=\"https://github.com/pmjones/AutoShell#autoshell\">documentation</a> to get started!</p>\n<hr>\n<p>You can read the Reddit discussion about this post <a href=\"https://old.reddit.com/r/PHP/comments/13rhko6/autoshell_10_released/\">here</a>.</p>\n"
}
