<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Richie</title>
    <description>The latest articles on DEV Community by Richie (@ricsam).</description>
    <link>https://dev.to/ricsam</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F186400%2F77d9392d-a15b-49af-8809-3c01cdb45142.png</url>
      <title>DEV Community: Richie</title>
      <link>https://dev.to/ricsam</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ricsam"/>
    <language>en</language>
    <item>
      <title>Publish a barebones CLI</title>
      <dc:creator>Richie</dc:creator>
      <pubDate>Wed, 09 Nov 2022 15:11:19 +0000</pubDate>
      <link>https://dev.to/ricsam/publish-a-barebones-cli-n2a</link>
      <guid>https://dev.to/ricsam/publish-a-barebones-cli-n2a</guid>
      <description>&lt;p&gt;You don't have to setup a bunch of tooling to just get started with a simple CLI.&lt;/p&gt;

&lt;p&gt;A package with little code is often a better start as an open source package because it is easier for contributors to help initially in a lightweight repository.&lt;/p&gt;

&lt;p&gt;To create a CLI make a folder:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;my-cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this folder run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm init &lt;span class="nt"&gt;-y&lt;/span&gt;
&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt; &amp;gt; cli.js
#!/usr/bin/env node
console.log('my cli');
&lt;/span&gt;&lt;span class="no"&gt;EOF
&lt;/span&gt;&lt;span class="nb"&gt;chmod&lt;/span&gt; +x cli.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;open the created package.json file and add:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"bin"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"my-cli"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"cli.js"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To test the cli in your shell run &lt;code&gt;npm link&lt;/code&gt; while in the package folder.&lt;/p&gt;

&lt;p&gt;You should now be able to run &lt;code&gt;my-cli&lt;/code&gt; in any terminal on your local machine.&lt;/p&gt;

&lt;p&gt;To publish to &lt;code&gt;npm&lt;/code&gt; update the package.json file with the correct details and run &lt;code&gt;npm publish&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Other people can now run &lt;code&gt;npm install -g my-cli&lt;/code&gt; to use your CLI.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>npm</category>
      <category>cli</category>
      <category>node</category>
    </item>
  </channel>
</rss>
