{"id":27617477,"url":"https://github.com/lukasl-dev/clark","last_synced_at":"2025-04-23T04:03:45.941Z","repository":{"id":40993842,"uuid":"322409138","full_name":"lukasl-dev/clark","owner":"lukasl-dev","description":"simple command-lexer for chat systems like discord, teamspeak or slack","archived":false,"fork":false,"pushed_at":"2023-04-05T10:58:16.000Z","size":76,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2024-06-20T22:37:28.535Z","etag":null,"topics":["cli","command","go","golang","lexer"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/lukasl-dev/clark","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lukasl-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-12-17T20:46:28.000Z","updated_at":"2022-07-10T20:58:59.000Z","dependencies_parsed_at":"2024-06-20T21:54:03.858Z","dependency_job_id":"6f35b332-d9f7-4a12-a5dd-73b87d99bbf8","html_url":"https://github.com/lukasl-dev/clark","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukasl-dev%2Fclark","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukasl-dev%2Fclark/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukasl-dev%2Fclark/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukasl-dev%2Fclark/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lukasl-dev","download_url":"https://codeload.github.com/lukasl-dev/clark/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250366708,"owners_count":21418770,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","command","go","golang","lexer"],"created_at":"2025-04-23T04:03:30.181Z","updated_at":"2025-04-23T04:03:45.898Z","avatar_url":"https://github.com/lukasl-dev.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# clark\n\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://golang.org/\"\u003e\n    \u003cimg\n      src=\"https://img.shields.io/badge/MADE%20WITH-GO-%23EF4041?style=for-the-badge\"\n      height=\"30\"\n    /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://pkg.go.dev/github.com/lukasl-dev/clark\"\u003e\n    \u003cimg\n      src=\"https://img.shields.io/badge/godoc-reference-5272B4.svg?style=for-the-badge\"\n      height=\"30\"\n    /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://goreportcard.com/report/github.com/lukasl-dev/clark\"\u003e\n    \u003cimg\n      src=\"https://goreportcard.com/badge/github.com/lukasl-dev/clark?style=for-the-badge\"\n      height=\"30\"\n    /\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n\u003cbr\u003e\n\n- [clark](#clark)\n    - [What is `clark`?](#what-is-clark)\n    - [Prerequisites](#prerequisites)\n    - [Installation](#installation)\n        - [Install the package](#install-the-package)\n        - [Install the CLI](#install-the-cli)\n    - [Getting started](#getting-started)\n        - [Create a Reader](#create-a-reader)\n        - [Create a Lexer](#create-a-lexer)\n            - [Available Options](#available-options)\n        - [Start the lexing progress](#start-the-lexing-progress)\n        - [Collect the lexed Tokens](#collect-the-lexed-tokens)\n    - [Usage of the CLI](#usage-of-the-cli)\n\n---\n\n## What is `clark`?\n\n`Clark` is a simple command-lexing package designed for chat systems such as Discord, Teamspeak, or Telegram. It is\ntherefore intended to facilitate the handling of user input and the parsing processes that follow.\n\n---\n\n## Prerequisites\n\nTo use a Go package such as `clark`, you must of course have Go installed on your system.\n\nIt is assumed that you have already worked with the Go environment. If this is not the case,\nsee [this page first](https://golang.org/doc/install).\n\n---\n\n## Installation\n\n### Install the package\n\nTo use `clark` as a Go package, you must have it installed on your current system. If this is not the case, run the\ncommand below.\n\n```console\ngo get -u github.com/lukasl-dev/clark\n```\n\n### Install the CLI\n\nOtherwise, if you want to use `clark` inside your terminal, you need to have it installed as well. If this is not the\ncase, run the command below.\n\nIf you have no experience in this section,\nread [this](https://golang.org/cmd/go/#hdr-Compile_and_install_packages_and_dependencies).\n\n```console\ngo get -u github.com/lukasl-dev/clark/cmd/clark\n```\n\n---\n\n## Getting started\n\n### Create a [Reader](https://pkg.go.dev/io#Reader)\n\nAs an example, we create a `strings.Reader` here.\n\n```go\nreader := strings.NewReader(\"!help\")\n```\n\n### Create a [Lexer](https://pkg.go.dev/github.com/lukasl-dev/clark/lexing#Lexer)\n\n```go\nlex, err := clark.NewLexer(reader)\n```\n\nYou can configure the [lexer](https://pkg.go.dev/github.com/lukasl-dev/clark/lexing#Lexer) using the\nvariadic [options](https://pkg.go.dev/github.com/lukasl-dev/clark#Option).\n\nSee [available Options](#available-options).\n\n```go\nlex, err := clark.NewLexer(\n  reader,\n  lexing.Prefixes(\"!\"), lexing.Labels(\"help\", \"play\", \"help me\"),\n)\n\n// handle error\n```\n\n#### Available [Options](https://pkg.go.dev/github.com/lukasl-dev/clark#Option)\n\n| Function                                                                                            |                                              Description |\n| :-------------------------------------------------------------------------------------------------- | -------------------------------------------------------: |\n| [`lexing.Prefixes`](https://pkg.go.dev/github.com/lukasl-dev/clark/lexing#Prefixes)                 |         Prefixes defines the prefixes used by the lexer. |\n| [`lexing.Labels`](https://pkg.go.dev/github.com/lukasl-dev/clark/lexing#Labels)                     |             Labels defines the labels used by the lexer. |\n| [`lexing.PrefixIgnoreCase`](https://pkg.go.dev/github.com/lukasl-dev/clark/lexing#PrefixIgnoreCase) |  PrefixIgnoreCase defines the prefixes case sensitivity. |\n| [`lexing.LabelIgnoreCase`](https://pkg.go.dev/github.com/lukasl-dev/clark/lexing#LabelIgnoreCase)   |     LabelIgnoreCase defines the labels case sensitivity. |\n| [`lexing.SkipPrefix`](https://pkg.go.dev/github.com/lukasl-dev/clark/lexing#SkipPrefix)             | SkipPrefix defines whether the prefix should be skipped. |\n| [`lexing.SkipLabel`](https://pkg.go.dev/github.com/lukasl-dev/clark/lexing#SkipLabel)               |   SkipLabel defines whether the label should be skipped. |\n\n### Start the lexing progress\n\nTo execute the [Lexer](https://pkg.go.dev/github.com/lukasl-dev/clark/lexing#Lexer)\n, `lex.Lex()` is executed as a goroutine. `lex.Lex()` reads the passed reader lexicographically until `io.EOF` and\nreturns the lexed [tokens](https://pkg.go.dev/github.com/lukasl-dev/clark/lexing/token#Token).\n\n```go\ngo lex.Lex()\n```\n\n### Collect the lexed [Tokens](https://pkg.go.dev/github.com/lukasl-dev/clark/lexing/token#Token)\n\nDuring reading [tokens](https://pkg.go.dev/github.com/lukasl-dev/clark/lexing/token#Token) are sent to the token\nchannel. This channel can be accessed via `lex.Chan()`.\n\n```go\nfor token := range lex.Chan() {\n// handle token\n}\n```\n\nA [Token](https://pkg.go.dev/github.com/lukasl-dev/clark/lexing/token#Token) has\na [Type](https://pkg.go.dev/github.com/lukasl-dev/clark/lexing/token#Type) and an optional value.\n\nSee supported [types](https://pkg.go.dev/github.com/lukasl-dev/clark/lexing/token#Type).\n\n---\n\n## Usage of the CLI\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukasl-dev%2Fclark","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flukasl-dev%2Fclark","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukasl-dev%2Fclark/lists"}