Skip to content

leaanthony/clir

Folders and files

NameName
Last commit message
Last commit date

Latest commit

a8d9462 · Jun 10, 2024

History

86 Commits
Jun 10, 2024
May 9, 2024
May 9, 2024
Jan 24, 2023
May 9, 2024
Nov 18, 2019
Jan 23, 2023
Nov 21, 2019
Jun 10, 2024
May 7, 2024
Dec 30, 2019
Apr 16, 2022
Nov 26, 2019
May 9, 2024
May 7, 2024
Nov 23, 2019
Nov 23, 2019

Repository files navigation


A Simple and Clear CLI library. Dependency free.

Awesome CodeFactor

Features

  • Nested Subcommands
  • Uses the standard library flag package
  • Struct based flags
  • Positional Args
  • Auto-generated help
  • Custom banners
  • Hidden Subcommands
  • Default Subcommand
  • Dependency free

Example

package main

import (
	"fmt"

	"github.com/leaanthony/clir"
)

func main() {
	// Create new cli
	cli := clir.NewCli("Flags", "A simple example", "v0.0.1")

	// Name
	name := "Anonymous"
	cli.StringFlag("name", "Your name", &name)

	// Define action for the command
	cli.Action(func() error {
		fmt.Printf("Hello %s!\n", name)
		return nil
	})

	if err := cli.Run(); err != nil {
		fmt.Printf("Error encountered: %v\n", err)
	}
}

Generated Help

$ flags --help
Flags v0.0.1 - A simple example

Flags:

  -help
        Get help on the 'flags' command.
  -name string
        Your name

Documentation

The main documentation may be found here.

License Status

FOSSA Status