<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Cobra on BradCypert.com</title>
    <link>https://www.bradcypert.com/tags/cobra/</link>
    <description>Recent content in Cobra on BradCypert.com</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Tue, 27 Dec 2022 16:51:00 -0500</lastBuildDate>
    <atom:link href="https://www.bradcypert.com/tags/cobra/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Testing a Cobra CLI in Go</title>
      <link>https://www.bradcypert.com/testing-a-cobra-cli-in-go/</link>
      <pubDate>Thu, 18 Jul 2019 00:00:00 +0000</pubDate>
      <guid>https://www.bradcypert.com/testing-a-cobra-cli-in-go/</guid>
      <description>&lt;p&gt;Go has a &lt;a href=&#34;https://github.com/spf13/cobra&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;fantastic library for writing CLI’s (Command Line Interfaces) called Cobra&lt;/a&gt;&#xA;. I’ve been working on a &lt;a href=&#34;https://github.com/bradcypert/deckard&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;CLI named Deckard&lt;/a&gt;&#xA; for a few months now. Being new to Go, I had (lazily) shied away from writing tests. However, after thinking about my test plan and doing a little refactoring, I’ve found a great way to handle testing your Cobra CLI application.&lt;/p&gt;&#xA;&lt;p&gt;The idea behind Cobra is that you simply write “Command” functions. These command functions are then called by the Cobra library when it parses a valid command. This means that Cobra handles a lot of the heavy lifting here, and because of that, has a pretty opinionated project structure. Thankfully, Cobra also has a CLI that makes starting a new cobra project a breeze.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
