<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Awesome Command Line - Medium]]></title>
        <description><![CDATA[Command Line is an awesome tool for developers. It boosts up developer’s productive. The publication writes command line tips for software engineers. - Medium]]></description>
        <link>https://medium.com/pragmatic-command-line?source=rss----fee0b97fd335---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Awesome Command Line - Medium</title>
            <link>https://medium.com/pragmatic-command-line?source=rss----fee0b97fd335---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 12:05:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/pragmatic-command-line" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to Design a Better Command Line Interface]]></title>
            <link>https://medium.com/pragmatic-command-line/how-to-design-a-better-command-line-interface-81269f0e0d62?source=rss----fee0b97fd335---4</link>
            <guid isPermaLink="false">https://medium.com/p/81269f0e0d62</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[developer-productivity]]></category>
            <category><![CDATA[command-line]]></category>
            <category><![CDATA[shell]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[Jian Lyu]]></dc:creator>
            <pubDate>Wed, 06 Apr 2022 13:58:13 GMT</pubDate>
            <atom:updated>2022-04-06T14:02:17.664Z</atom:updated>
            <content:encoded><![CDATA[<p>3 Patterns can help you to build a user friendly Command Line Interface from today.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wP3bkJO7o0ywsVk8" /><figcaption>Photo by <a href="https://unsplash.com/@kellysikkema?utm_source=medium&amp;utm_medium=referral">Kelly Sikkema</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Pattern 1 — Naming as Command</h3><p>Simplest command line, no arguments, the name describe the functionality. Most of time it reduces complex process into a single command. The best sample is install.sh .</p><p><strong>In order to create this simple command line, we need:</strong></p><ul><li>A shell script file</li><li>Grant execute permission to the file</li></ul><p>Here is a sample for running a database in Docker:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eaed81c034ffbbae861ecedef50f4bad/href">https://medium.com/media/eaed81c034ffbbae861ecedef50f4bad/href</a></iframe><p>Then grant permission to the file</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/22616bf22e37a4b3fc70d0792f0a75cb/href">https://medium.com/media/22616bf22e37a4b3fc70d0792f0a75cb/href</a></iframe><p>Run it:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fee52c403a12ef7be2617850ab391e71/href">https://medium.com/media/fee52c403a12ef7be2617850ab391e71/href</a></iframe><p>On creating the run-db.sh , it doesn’t have execute permission, we have to grant permission with chmod +x run-db .</p><h3>Pattern 2 — Command with arguments</h3><p>A command can take arguments. e.g: curl www.google.com. It adds a little bit complexity.</p><p><strong>In order to create this command line, we need:</strong></p><ul><li>A usage for arguments</li><li>Validation for Arguments</li><li>Parse the input</li></ul><p>Here we extend the run-db.sh to accept version.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c887a5a735f54762a2dd8abd49b214e0/href">https://medium.com/media/c887a5a735f54762a2dd8abd49b214e0/href</a></iframe><p>The command prints usage by default:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e77cf5da824eb3f5f5fa95fa7b529ed6/href">https://medium.com/media/e77cf5da824eb3f5f5fa95fa7b529ed6/href</a></iframe><p>It takes a version for running:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9d6f4d3bd2e6d50a64fa50ca61995fd8/href">https://medium.com/media/9d6f4d3bd2e6d50a64fa50ca61995fd8/href</a></iframe><h3>Pattern 3 — Git-like Command Line</h3><p>The most powerful command line interface, it looks like git. It organises a bunch of commands into the pattern: Command &lt;Sub-command&gt; [ARGS] . It’s a popular pattern for Command line interface, e.g: aws-cli , rails and docker etc.</p><p>In order to create a git-like command line, we need</p><ul><li>A comprehensive usage for each Sub-Commands and their arguments</li><li>Arguments validation</li><li>Process Sub-Command</li><li>Parse the arguments of Sub-Command</li></ul><p>Let’s extend the rub-db command again to support run , kill and rm Sub-Commands.</p><p>The usage document:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2163ac26062ee9a53ff4951eadab5e94/href">https://medium.com/media/2163ac26062ee9a53ff4951eadab5e94/href</a></iframe><p>The usage:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/804179547b44f7bcede3be16938e4f82/href">https://medium.com/media/804179547b44f7bcede3be16938e4f82/href</a></iframe><p>The actual code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a3aef2dbe9c66c56a766ad3faf844754/href">https://medium.com/media/a3aef2dbe9c66c56a766ad3faf844754/href</a></iframe><p>The magic here is the $@ , it captures the rest of the command run 14.2 and run it. The run function will take 14.2 as a parameter.</p><h3>3 Patterns in Practice</h3><p>There are some practical tips you take to improve your project from today.</p><h4>Pattern 1 — Naming as Command</h4><p>On building micro-services, there are so many variations to run each services. ./bin/run.sh command is a way to solve the problem. We can create it for each services, the Dockerfile will be decoupled from the tech details.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/da6b96e5b4f866915ffaca1ee8d62b7a/href">https://medium.com/media/da6b96e5b4f866915ffaca1ee8d62b7a/href</a></iframe><p>./script/bootstrap.sh is a best way to help people setup development environment. Unless someone like to maintain a boring Dev Setup document.</p><h4>Pattern 2 — Command with arguments</h4><p>ssh-ec2 connect to EC2 instance by name. I built it, it saved my huge amount of time on finding IP and connecting to EC 2 instances.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1fe7b5fde9c1337ad578cb48a029ccb3/href">https://medium.com/media/1fe7b5fde9c1337ad578cb48a029ccb3/href</a></iframe><h4>Pattern 3 — Git-like Command Line</h4><p>A command to control <a href="https://en.wikipedia.org/wiki/Extract,_transform,_load">ETL</a> service:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8fed3e384c477487c03b1e2dcc30bf65/href">https://medium.com/media/8fed3e384c477487c03b1e2dcc30bf65/href</a></iframe><p>Or, managing SQS &amp; SNS infra via a command:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9cc65fc626b2398cd6c9d8623023581c/href">https://medium.com/media/9cc65fc626b2398cd6c9d8623023581c/href</a></iframe><h3>The end.</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=81269f0e0d62" width="1" height="1" alt=""><hr><p><a href="https://medium.com/pragmatic-command-line/how-to-design-a-better-command-line-interface-81269f0e0d62">How to Design a Better Command Line Interface</a> was originally published in <a href="https://medium.com/pragmatic-command-line">Awesome Command Line</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>