Categorygithub.com/Phantas0s/gocli
repositorypackage
0.0.0-20211016134417-4748d99b847a
Repository: https://github.com/phantas0s/gocli.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

gocli

A template to create CLI in Golang.

Highlights

  • Default commands (help, version).
  • Possibility to configure each flag via config file.
  • Automatic generation of environment variable.
  • Easy way to create app releases.
  • Script to automatically install your CLI on Linux.

Installation

  1. Clone this repository with the name of your new CLI (replace greatcli with something else):
git clone https://github.com/Phantas0s/gocli greatcli
  1. Run go build in your new project. You've just compiled the example CLI!
  2. Run ./gocli: the CLI binary works.

Usage

Trying the Example

The example CLI has three commands by default:

  • version - Display the CLI's version.
  • help - Display the help of the command. For the general help: ./gocli help. For a command's help: ./gocli <command> --help.
  • example - A dummy command.

If you try ./gocli version, you'll notice that the version number is missing. It's because your CLI needs to be released to have a version. See the section "Releasing your Cli".

Creating your CLI

First, let's edit main.go. Replace every instance of gocli with the name of your cli.

Defining the Command and the Flags

Adding A Flag

Releasing Your CLI

  • Need a git tag
  • Need to be in a clean state (git)

Linux script

If you use a Linux-based OS, here's a simple way to download gocli and move it to /usr/local/bin. You can then call it wherever you want.

curl -L https://raw.githubusercontent.com/Phantas0s/<my_cli>/master/install/linux.sh | bash

Navigation

  or k: up
  or j: down
 PgUp or CTRL+u: One screen up
 PgDn or CTRL+d: One screen down
 Home or g: Top of the list
 End or G: Bottom of the list

Action

 ENTER: Open the selected page with your favorite browser
 d: Delete Pocket entry
 a: Add (if list archive) or archive (if list unread)

Sponsorship

Consider sponsoring my work if you want to see new, fresh, and crunchy little CLIs (and TUIs) all over your system.

Building Your Mouseless Environment

Switching between a keyboard and mouse costs cognitive energy. My book will help you set up a Linux-based development environment that keeps your hands on your keyboard. Take the brain power you've been using to juggle input devices and focus it where it belongs: on the things you create.

Licence

Apache Licence 2.0