<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Usage on Go Subcommand</title><link>https://arran4.github.io/go-subcommand/docs/usage/</link><description>Recent content in Usage on Go Subcommand</description><generator>Hugo</generator><language>en-us</language><atom:link href="https://arran4.github.io/go-subcommand/docs/usage/index.xml" rel="self" type="application/rss+xml"/><item><title>Getting Started</title><link>https://arran4.github.io/go-subcommand/docs/usage/getting-started/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://arran4.github.io/go-subcommand/docs/usage/getting-started/</guid><description>&lt;h1 id="getting-started"&gt;Getting Started&lt;a class="anchor" href="#getting-started"&gt;#&lt;/a&gt;&lt;/h1&gt;&#10;&lt;p&gt;Let&amp;rsquo;s build a simple CLI application named &lt;code&gt;greet&lt;/code&gt;.&lt;/p&gt;&#10;&lt;h2 id="1-create-a-go-module"&gt;1. Create a Go Module&lt;a class="anchor" href="#1-create-a-go-module"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mkdir greet&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cd greet&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;go mod init example.com/greet&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="2-define-a-command"&gt;2. Define a Command&lt;a class="anchor" href="#2-define-a-command"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;Create &lt;code&gt;main.go&lt;/code&gt; and define your command function.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-go" data-lang="go"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;package&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;main&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;import&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;fmt&amp;#34;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;// Hello is a subcommand `greet hello`&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;// Prints a greeting.&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;func&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;Hello&lt;/span&gt;(&lt;span style="color:#a6e22e"&gt;name&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;string&lt;/span&gt;) {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;fmt&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;Printf&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#34;Hello, %s!\n&amp;#34;&lt;/span&gt;, &lt;span style="color:#a6e22e"&gt;name&lt;/span&gt;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;func&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;main&lt;/span&gt;() {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;// This will be replaced by the generated code usage,&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;// but for now you can leave it empty or use it to run the generated cmd.&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="3-configure-generation"&gt;3. Configure Generation&lt;a class="anchor" href="#3-configure-generation"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;Create a &lt;code&gt;generate.go&lt;/code&gt; file to instruct &lt;code&gt;go generate&lt;/code&gt;.&lt;/p&gt;</description></item><item><title>Defining Commands</title><link>https://arran4.github.io/go-subcommand/docs/usage/defining-commands/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://arran4.github.io/go-subcommand/docs/usage/defining-commands/</guid><description>&lt;h1 id="defining-commands"&gt;Defining Commands&lt;a class="anchor" href="#defining-commands"&gt;#&lt;/a&gt;&lt;/h1&gt;&#10;&lt;p&gt;Commands are defined by adding specific comments to your Go functions.&lt;/p&gt;&#10;&lt;h2 id="syntax"&gt;Syntax&lt;a class="anchor" href="#syntax"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-go" data-lang="go"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;// FunctionName is a subcommand `root-cmd sub-cmd...`&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;// Description text...&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;FunctionName&lt;/strong&gt;: The name of the Go function to execute.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;root-cmd&lt;/strong&gt;: The name of your root application (e.g., &lt;code&gt;git&lt;/code&gt;, &lt;code&gt;kubectl&lt;/code&gt;).&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;sub-cmd&amp;hellip;&lt;/strong&gt;: A space-separated list of subcommands (e.g., &lt;code&gt;remote add&lt;/code&gt;).&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h2 id="description"&gt;Description&lt;a class="anchor" href="#description"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;The text following the command definition or on subsequent lines is used as the command description in usage text.&lt;/p&gt;</description></item><item><title>Flags &amp; Parameters</title><link>https://arran4.github.io/go-subcommand/docs/usage/flags-parameters/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://arran4.github.io/go-subcommand/docs/usage/flags-parameters/</guid><description>&lt;h1 id="flags--parameters"&gt;Flags &amp;amp; Parameters&lt;a class="anchor" href="#flags--parameters"&gt;#&lt;/a&gt;&lt;/h1&gt;&#10;&lt;p&gt;&lt;code&gt;go-subcommand&lt;/code&gt; automatically maps your function parameters to command-line flags and arguments.&lt;/p&gt;&#10;&lt;h2 id="automatic-mapping"&gt;Automatic Mapping&lt;a class="anchor" href="#automatic-mapping"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;Function parameters are converted to flags by default.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-go" data-lang="go"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;func&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;Server&lt;/span&gt;(&lt;span style="color:#a6e22e"&gt;port&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;int&lt;/span&gt;, &lt;span style="color:#a6e22e"&gt;verbose&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;bool&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Generates flags:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;code&gt;--port &amp;lt;int&amp;gt;&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;--verbose&lt;/code&gt; (boolean flag)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Flag names are automatically converted to kebab-case (e.g., &lt;code&gt;maxRetries&lt;/code&gt; -&amp;gt; &lt;code&gt;--max-retries&lt;/code&gt;).&lt;/p&gt;&#10;&lt;h2 id="customizing-flags"&gt;Customizing Flags&lt;a class="anchor" href="#customizing-flags"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;You can customize flags using comments. There are three ways to define them, in order of priority:&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;&lt;strong&gt;Flags Block&lt;/strong&gt;: A &lt;code&gt;Flags:&lt;/code&gt; block in the function documentation.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Inline Comment&lt;/strong&gt;: Comment on the same line as the parameter.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Preceding Comment&lt;/strong&gt;: Comment on the line before the parameter.&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;h3 id="1-flags-block-highest-priority"&gt;1. Flags Block (Highest Priority)&lt;a class="anchor" href="#1-flags-block-highest-priority"&gt;#&lt;/a&gt;&lt;/h3&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-go" data-lang="go"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;// MyCmd is a subcommand `app cmd`&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;// Flags:&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;// port: default: 8080 description: Port to listen on&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;func&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;MyCmd&lt;/span&gt;(&lt;span style="color:#a6e22e"&gt;port&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;int&lt;/span&gt;) {}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="2-inline-comment"&gt;2. Inline Comment&lt;a class="anchor" href="#2-inline-comment"&gt;#&lt;/a&gt;&lt;/h3&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-go" data-lang="go"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;func&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;MyCmd&lt;/span&gt;(&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;port&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;int&lt;/span&gt;, &lt;span style="color:#75715e"&gt;// default: 8080 description: Port to listen on&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;) {}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="3-preceding-comment"&gt;3. Preceding Comment&lt;a class="anchor" href="#3-preceding-comment"&gt;#&lt;/a&gt;&lt;/h3&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-go" data-lang="go"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;// default: 8080 description: Port to listen on&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;port&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;int&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="syntax-reference"&gt;Syntax Reference&lt;a class="anchor" href="#syntax-reference"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;The parameter definition syntax supports several attributes:&lt;/p&gt;</description></item><item><title>Agent Skills</title><link>https://arran4.github.io/go-subcommand/docs/usage/skills/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://arran4.github.io/go-subcommand/docs/usage/skills/</guid><description>&lt;h1 id="agent-skills"&gt;Agent Skills&lt;a class="anchor" href="#agent-skills"&gt;#&lt;/a&gt;&lt;/h1&gt;&#10;&lt;p&gt;&lt;code&gt;gosubc&lt;/code&gt; supports installing and managing &lt;strong&gt;AI Agent Skills&lt;/strong&gt;. Skills are Markdown files (&lt;code&gt;SKILL.md&lt;/code&gt;) and supporting files that teach AI coding assistants (like Cursor, Copilot, or generic agents) how to use your CLI properly.&lt;/p&gt;&#10;&lt;h2 id="managing-skills"&gt;Managing Skills&lt;a class="anchor" href="#managing-skills"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;&lt;code&gt;gosubc&lt;/code&gt; includes a built-in &lt;code&gt;skill&lt;/code&gt; command group to manage these agent instructions.&lt;/p&gt;&#10;&lt;h3 id="installing-a-skill"&gt;Installing a Skill&lt;a class="anchor" href="#installing-a-skill"&gt;#&lt;/a&gt;&lt;/h3&gt;&#10;&lt;p&gt;You can install a skill from a local directory or a remote git repository.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Install a local skill&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;gosubc skill install ./my-local-skill&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Install a skill from a GitHub repository (e.g., github.com/owner/repo)&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;gosubc skill install owner/repo&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Scopes:&lt;/strong&gt;&#10;By default, skills are installed to the &lt;code&gt;user&lt;/code&gt; scope (e.g., &lt;code&gt;~/.agents/skills/&lt;/code&gt;). You can install a skill for a specific project by using &lt;code&gt;--scope project&lt;/code&gt;, which places it in &lt;code&gt;.agents/skills/&lt;/code&gt; in your current working directory.&lt;/p&gt;</description></item></channel></rss>