Skip to content

Highly customizable and idiomatic Go CLI app framework ๐Ÿ‘Œ

License

Notifications You must be signed in to change notification settings

SuperPaintman/nice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Nice ๐Ÿ‘Œ

Nice is a highly customizable and lightweight framework for crafting CLI apps.

Nice respects idiomatic Go code and focuses to be clear, efficient and easy to write and maintain.

You can use it as a full-featured non-opinionated framework or use any nice packages as stand-alone libraries.

I hope you'll enjoy your nice CLI app!

Banner


Table of Contents


Hello, Nice!

Let's start with your first Nice CLI app.

First, install the framework:

$ go get github.com/SuperPaintman/nice/cli

Then put this code into a file (hello.go for example):

package main

import "github.com/SuperPaintman/nice/cli"

func main() {
	app := cli.App{
		Name:  "hello",
		Usage: cli.Usage("Print a friendly greeting"),
		Action: cli.ActionFunc(func(cmd *cli.Command) cli.ActionRunner {
			name := cli.StringArg(cmd, "name",
				cli.Usage("Who we say hello to"),
				cli.Optional,
			)
			*name = "Nice" // Default value.

			return func(cmd *cli.Command) error {
				cmd.Printf("Hello, %s!\n", *name)

				return nil
			}
		}),
		CommandFlags: []cli.CommandFlag{
			cli.HelpCommandFlag(),
			cli.VersionCommandFlag("0.0.0"),
		},
	}

	app.HandleError(app.Run())
}

Now you can run it!

$ go run . world

Or print the help for your app:

$ go run . -h

Help example


Examples

You can find more examples in the ./examples directory.


Packages

๐Ÿ–ฅ๏ธ github.com/SuperPaintman/nice/cli

Documentation โ€ข Source

import "github.com/SuperPaintman/nice/cli"

๐Ÿ–Œ๏ธ github.com/SuperPaintman/nice/colors

Documentation โ€ข Source

import "github.com/SuperPaintman/nice/colors"

Tests

$ go test -race ./...
$ go test ./... -bench=. -benchmem -run='^Benckmark'

Similar projects


License

MIT


With ๐Ÿซ€ by Aleksandr Krivoshchekov (@SuperPaintman)

About

Highly customizable and idiomatic Go CLI app framework ๐Ÿ‘Œ

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published