cli-template


A template for beautiful, modern, cross-platform compatible CLI tools written with Go!

Screenshot


Getting Started | Wiki


This template features
Modern Style

💎

Build on top of cobra

🐍

Automatic Releases

🚀

Easy installation for your users (one command)

🐥

Automatic Website/Docs Generation

🌐

Automatic Deployment

🔝

Update Checking


Custom CI-System

🤖

Custom Libraries

🔬

Getting Started

You can find an in-depth tutorial in the Wiki here: Getting Started

  1. Click on Use this template on the top of the page.
  2. Enable GitHub Pages and set the path to /docs.
  3. Create a personal access token (with repo scope) and add it as a repository secret (name: REPO_ACCESS_TOKEN).
  4. Clone and open your repository to change the description of your CLI in ./cmd/root.go.
  5. After you have set up your programm you have to create the very first release manually (v0.0.1), to initialize the CI-System. (Don’t worry if your CLI tool doesn’t do anything yet. It’s common that the v0.0.1 release is just the plain project setup)
  6. The setup is done and you can start to code!

This template uses spf13/cobra as CLI framework.
You can find their documentation here: cobra.dev

Features

Modern Style

PTerm Documentation Link

This template uses PTerm to provide colorful, cross-platform compatible output by default!
By using PTerm, you can output progressbars, colored text, charts and many more.

Build on top of cobra

Cobra Documentation Link

Cobra is a popular CLI framework for Go.

Automatic Releases

Documentation link

Our custom made CI system will detect when you change the version of your CLI and will automatically create a new GitHub release for you. You’ll never have to deploy your CLI tools manually again!

Install Ready

Instl Documentation link

The automatic releases contain binaries, for the most common operating systems.
This binaries can be installed using instl.sh.

This means that your users, can install your CLI Tool with a single command!
The command will automatically be put into your README.md, after you click Use this template.

The commands will look like below, depending on the OS, your user has.

Windows

iwr instl.sh/username/reponame/windows | iex 

macOS

curl -sSL instl.sh/username/reponame/macos | sudo bash   

Linux

curl -sSL instl.sh/username/reponame/linux | sudo bash  

Automatic Website Generation

Documentation link

Every time you push a new commit, a GitHub Pages website is created/updated, which documents your whole CLI tool automatically. You don’t need to document anything by yourself.

You only need to enable GitHub Pages by going to your repository settings (set the path to /docs).

Automatic Deployment

Goreleaser Documentation link

This template uses Goreleaser to build binaries of GitHub releases, for the most common operating systems.
Since we feature Automatic Releases, your whole deployment process is automated, when you increase the version of your CLI tool.

Update Checking

Your users will be notified if a new version of your tool is availble.

Custom CI-System

Documentation link

We wrote a custom CI-System, which will be included in your repository.
It sets up the template, creates/updates the website, writes docs for you and run your tests. (And much more!)

Custom Libraries

We use libraries, which were specially made for this template, to give you the best user experience without a ton of code.

GitHub

https://github.com/pterm/cli-template