Skip to content

JamesPatrickGill/applause

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Applause - a shameless clap.rs ripoff

A simple command-line argument parsing library for Go with a builder pattern interface.

⚠️ Draft Status: This library is currently in development and the API may change.

Features

  • Builder pattern for easy CLI definition
  • Support for positional arguments and flags (short and long)
  • Subcommands support
  • Automatic help and version flags
  • Simple argument parsing and value retrieval

Installation

go get github.com/JamesPatrickGill/applause

Quick Example

package main

import (
    "fmt"
    "os"

    "github.com/JamesPatrickGill/applause"
)

func main() {
    // Define your CLI
    cmd := applause.NewCommand("greet").
        Version("1.0.0").
        About("A simple greeting application").
        Arg(applause.NewArg("name").Help("Name to greet")).
        Arg(applause.NewArg("greeting").Short("g").Long("greeting").Help("Custom greeting"))

    // Parse arguments
    matches := cmd.GetMatchesFrom(os.Args)

    // Get values
    name := "World"
    if n, ok := matches.GetPositional(0); ok {
        name = n
    }

    greeting := "Hello"
    if g, ok := matches.GetOne("greeting"); ok {
        greeting = g
    }

    fmt.Printf("%s, %s!\n", greeting, name)
}

Usage:

$ greet Alice
Hello, Alice!

$ greet Bob --greeting "Hi"
Hi, Bob!

$ greet --help
greet 1.0.0
A simple greeting application
...

License

This project is open source and available under the MIT License.

About

A shameless clap.rs ripoff

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages