Skip to content

deniskorbakov/skeleton-cli-go

Repository files navigation

Skeleton CLI GO

Go Report Card Release Action Lint GitHub Repo stars

A template for creating console applications on go using TUI

Made using data from packages:

  • Cobra - Library for creating powerful modern CLI applications
  • Fang - The CLI starter kit
  • Huh - A simple interactive forms and prompts in the terminal

What do you get:

screen

✨ Install

clone the repository

git clone https://github.com/deniskorbakov/skeleton-cli-go.git

go to the project folder

cd skeleton-cli-go

build the app

make build

launch the app

./cli

📖 Examples & Usage

↘️ Replace

In order to reuse the project for your application, you need to replace the following items

Change the path to the cli to the name of your utility cmd/cli -> cmd/your_name_cli

In the .goreleaser.yaml file, you need to change the name of the cli to your utility

version: 2

env:
  - GO111MODULE=on

project_name: your_name_cli

Change the application name in the Makefile

build:
	go mod vendor
	go build -ldflags "-w -s" -o your_name_cli cmd/your_name_cli/main.go

Change the application description in the root command - configs/constname/root.go

⌨️ Command

Commands are created in the directory - internal/command

We are creating a file based on the example of the file - internal/command/example.go

After creation, add the command to internal/command/root.go

package command

func Run() {
	// Other code
	cmd.AddCommand(
		exampleCmd,
		// Add new comments here
	)
}

⚙️ Configs

configs/constname - This directory contains files for the names of commands, their descriptions, etc.

You can add or change team data in this space

🗯️ Components

The components use huh

Running a burger form

The components in the application are located here - internal/component

These components can be either a form or a separate element of it - further logic depends on your needs

I described the standard example in the file - internal/component/form

We divide the logic into the form itself and what it outputs in a separate structure with fields that it returns

The application also uses the internal/component/output/output.go component. It is designed to display text in different colors

🗒️ Version

The app receives the version during the build using Goreleaser

The version that you specified in the repository when creating the new release will be installed

📝 Release

The release is being assembled with the help of Goreleaser

You can see exactly what is going on here - .goreleaser.yaml

✍️ Lint

the project has golangci-lint which adjusts your code

to launch it, specify - make lint

👻 GitHub Actions

Jobs are configured here to check the quality of the code through lint and also add binary files of your application for different OS

In order for the job release to work, you need to specify the GH token in the certificates of your project

The secret should be called - GO_RELEASER

🤝 Feedback

We appreciate your support and look forward to making our product even better with your help!

@Denis Korbakov

About

🦴 This template is for creating TUI CLI on Go

Topics

Resources

License

Stars

Watchers

Forks