Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sbstjn/allot
Parse placeholder and wildcard text commands
https://github.com/sbstjn/allot
chatops command go golang matching parsing pattern slackbot text
Last synced: 10 days ago
JSON representation
Parse placeholder and wildcard text commands
- Host: GitHub
- URL: https://github.com/sbstjn/allot
- Owner: sbstjn
- License: mit
- Created: 2016-10-16T15:49:08.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2022-01-31T09:04:19.000Z (almost 3 years ago)
- Last Synced: 2024-07-31T20:53:11.365Z (3 months ago)
- Topics: chatops, command, go, golang, matching, parsing, pattern, slackbot, text
- Language: Go
- Homepage:
- Size: 34.2 KB
- Stars: 59
- Watchers: 3
- Forks: 8
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-go - allot - Placeholder and wildcard text parsing for CLI tools and bots. (Text Processing / Parsers/Encoders/Decoders)
- awesome-go - allot - Parse placeholder and wildcard text commands - ★ 31 (Text Processing)
- awesome-go-extra - allot - 10-16T15:49:08Z|2022-01-31T09:04:19Z| (Bot Building / Parsers/Encoders/Decoders)
README
# allot [![MIT License](https://img.shields.io/github/license/sbstjn/allot.svg?maxAge=3600)](https://github.com/sbstjn/allot/blob/master/LICENSE.md) [![GoDoc](https://godoc.org/github.com/sbstjn/allot?status.svg)](https://godoc.org/github.com/sbstjn/allot) [![Go Report Card](https://goreportcard.com/badge/github.com/sbstjn/allot)](https://goreportcard.com/report/github.com/sbstjn/allot) [![allot - Coverage Status](https://img.shields.io/coveralls/sbstjn/allot.svg)](https://coveralls.io/github/sbstjn/allot) [![Build Status](https://img.shields.io/circleci/project/sbstjn/allot.svg?maxAge=600)](https://circleci.com/gh/sbstjn/allot)
**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
```go
cmd := allot.NewCommand("revert commits on at (stage|prod)")
match, err := cmd.Match("revert 12 commits on example at prod")if (err != nil)
commits, _ = match.Integer("commits")
project, _ = match.String("project")
env, _ = match.Match(2)fmt.Printf("Revert \"%d\" on \"%s\" at \"%s\"", commits, project, env)
} else {
fmt.Println("Request did not match command.")
}
```## Examples
See the [hanu Slackbot](https://github.com/sbstjn/hanu) framework for a usecase for **allot**:
* [Host a Golang Slack bot on Heroku](https://sbstjn.com/host-golang-slackbot-on-heroku-with-hanu.html)
## Credits
* [Go coverage script from Mathias Lafeldt](https://mlafeldt.github.io/blog/test-coverage-in-go/)