Take command of your go programs with Cobra 🐍

Donald Feury
2 min readAug 12, 2020

--

CLI applications are extremely handy to use. Building out a lot of the nice features that good CLI apps have can be a bit time consuming though.

At least, it was, until cobra was created and that changed everything.

Cobra is a go package that can be utilized to create very robust CLI applications with very little effort.

It provides an impressive list of features:

  • Subcommand-based CLIs
  • POSIX-compliant flags (short/long versions)
  • Nested subcommands
  • Global, local, and cascading flags (explained in video)
  • Application and command generator
  • Auto suggestions on command typos
  • Automatic help generation
  • Automatic help flag recognition
  • Generates shell autocompletion for bash, zsh, fish, and powershell
  • Generates documentation, such as man pages
  • Command aliases
  • Integrates very well with viper

Check out the video tutorial where I give some basic examples of the various features of cobra.

Shout out to my wife who makes these hilarious thumbnails, follow her on twitter and instagram for more art stuff.

If you liked it and want to know when I post more, be sure to subscribe and thank ya’ll again for your time!

This was originally posted on my blog

--

--

Donald Feury
Donald Feury

Written by Donald Feury

Appalachian Boi, Technology Consultant, Content Creator

No responses yet