allot

module
v1.2.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 12, 2022 License: MIT

README

allot MIT License GoDoc Go Report Card allot - Coverage Status Build Status

allot is a small Golang library to match and parse commands with pre-defined strings. For example use allot to define a list of commands your CLI application or Slackbot supports and check if incoming requests are matching your commands.

The allot library supports placeholders and regular expressions for parameter matching and parsing.

Usage

 cmd := allot.New("revert <commits:integer> commits on <project:string> at (stage|prod)")
 match, err := cmd.Match("revert 12 commits on example at prod")

 if err != nil {
  fmt.Println("Request did not match command.")
  os.Exit(1)
 }
 
 commits, _ := match.Integer("commits")
 project, _ := match.String("project")
 env, _ := match.Match(2)

 fmt.Printf("Revert \"%d\" on \"%s\" at \"%s\"", commits, project, env)  # Revert 12 on example at prod

Credits

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL