{"id":27775755,"url":"https://github.com/0x5a17ed/plainfields","last_synced_at":"2025-04-30T04:21:35.253Z","repository":{"id":290427055,"uuid":"974227729","full_name":"0x5a17ed/plainfields","owner":"0x5a17ed","description":"A lightweight, human-friendly configuration format for Go with simple syntax for fields, lists, and maps.","archived":false,"fork":false,"pushed_at":"2025-04-28T19:14:26.000Z","size":15,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-28T19:41:50.220Z","etag":null,"topics":["configuration-language","data-serialization","dsl","dsl-syntax","go","golang","golang-library","golang-package","lexer","parser"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"0bsd","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/0x5a17ed.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,"zenodo":null}},"created_at":"2025-04-28T12:59:26.000Z","updated_at":"2025-04-28T19:16:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"21608134-e1fb-428c-852d-962fee5170a7","html_url":"https://github.com/0x5a17ed/plainfields","commit_stats":null,"previous_names":["0x5a17ed/plainfields"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0x5a17ed%2Fplainfields","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0x5a17ed%2Fplainfields/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0x5a17ed%2Fplainfields/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0x5a17ed%2Fplainfields/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/0x5a17ed","download_url":"https://codeload.github.com/0x5a17ed/plainfields/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251639652,"owners_count":21619809,"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":["configuration-language","data-serialization","dsl","dsl-syntax","go","golang","golang-library","golang-package","lexer","parser"],"created_at":"2025-04-30T04:21:34.574Z","updated_at":"2025-04-30T04:21:35.247Z","avatar_url":"https://github.com/0x5a17ed.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PlainFields 🌱\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/0x5a17ed/plainfields.svg)](https://pkg.go.dev/github.com/0x5a17ed/plainfields)\n[![License: 0BSD](https://img.shields.io/badge/License-0BSD-blue.svg)](https://opensource.org/licenses/0BSD)\n\nPlainFields is a lightweight, human-friendly configuration language for Go applications. It provides a simple syntax for expressing structured data with fields, lists, and key-value pairs.\n\n```\nname=PlainFields, version=1.0.0, ^enabled, !deprecated, features=simple;human-readable;flexible, \nsettings=theme:dark;indent:4;display:compact\n```\n\n\n## ✨ Features\n\n- **🔤 Clean, minimal syntax**  \n  No curly braces, no complex nesting. Friendly to read and write by humans\n- **📏 Compact**  \n  Minimal syntax overhead, no deep nesting to navigate\n- **🔄 Boolean toggles**  \n  Use `^feature` to enable, `!feature` to disable\n- **📋 Lists and maps**  \n  Simple syntax for collections: `tags=red;green;blue` `font=family:Arial;size:12`\n- **⚡ Event-based parser**  \n  Efficient parsing and serialization with a streaming parser API\n- **🔨 Fluent builder API**  \n  Programmatically create plainfields strings\n- **🧩 Zero dependencies**  \n  Just pure Go standard library, no `reflect` used\n\n\n## 📦 Installation\n\n```bash\ngo get -u github.com/0x5a17ed/plainfields\n```\n\n\n## 🚀 Quick Start\n\n\n### 🔍 Parsing PlainFields\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\n\t\"github.com/0x5a17ed/plainfields\"\n)\n\nfunc main() {\n\tinput := \"^enabled, name=john, settings=theme:dark;fontSize:14\"\n\ttokens := plainfields.Lex(input)\n\n\tfor event := range plainfields.Parse(tokens) {\n\t\tswitch e := event.(type) {\n\t\tcase plainfields.FieldStartEvent:\n\t\t\tfmt.Printf(\"  Field: %s\\n\", e.Name)\n\t\tcase plainfields.ValueEvent:\n\t\t\tfmt.Printf(\"  Value: %s\\n\", e.Value)\n\t\tcase plainfields.MapStartEvent:\n\t\t\tfmt.Printf(\"    Map:\\n\")\n\t\tcase plainfields.MapKeyEvent:\n\t\t\tfmt.Printf(\"    Key: %s\\n\", e.Value)\n\t\t}\n\t}\n}\n\n```\n\n\n### ✏️ Creating PlainFields\n\n```go\nbuilder := plainfields.NewBuilder()\nresult := builder.\n\tEnable(\"feature\").\n\tField(\"name\", \"john\").\n\tList(\"tags\", \"dev\", \"prod\").\n\tPairs(\"settings\", \"theme\", \"dark\", \"fontSize\", 14).\n\tString()\n\nfmt.Println(result)\n// Output: ^feature,name=john,tags=dev;prod,settings=theme:dark;fontSize:14\n```\n\n\n## 📝 Syntax\n\nPlainFields uses a simple, flat structure:\n\n- **Fields** are comma-separated: `name=john, age=30`\n- **Boolean toggles** use prefixes: `^enabled`, `!disabled`\n- **Lists** use semicolons: `tags=red;green;blue`\n- **Maps** (key-value pairs) use colon and semicolon: `settings=theme:dark;fontSize:14`\n- **Blank spaces** are allowed around syntax elements\n\n\n### 🧪 Data Types\n\n- **Strings**: `name=john` or `message=\"Hello, world!\"` (quotes for special chars)\n- **Numbers**: `age=30`, `pi=3.14`, `hex=0xFF`, `binary=0b1010`\n- **Booleans**: `active=true` or `valid=false`\n- **Lists**: `colors=red;green;blue`\n- **Maps**: `settings=theme:dark;fontSize:14`\n- **Null**: `value=nil`\n\n\n## 📚 Detailed Usage\n\n### 🛠️ Builder with Options\n\n```go\noptions := plainfields.BuilderOptions{\n\tSpaceAfterFieldSeparator:   true,\n\tSpaceAfterListSeparator:    true,\n\tSpaceAfterPairsSeparator:   true,\n\tSpaceAroundFieldAssignment: true,\n}\n\nbuilder := plainfields.NewBuilderWithOptions(options)\nresult := builder.\n\tEnable(\"feature\").\n\tField(\"name\", \"john\").\n\tList(\"tags\", \"dev\", \"prod\").\n\tPairs(\"settings\", \"theme\", \"dark\", \"fontSize\", 14).\n\tString()\n\nfmt.Println(result)\n// Output: ^feature, name = john, tags = dev; prod, settings = theme: dark; fontSize: 14\n```\n\n\n## 📜 License\n\nThis project is licensed under the 0BSD Licence — see the [LICENCE](LICENSE) file for details.\n\n---\n\n\u003cp align=\"center\"\u003eMade with ❤️ for structured data 🌟\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0x5a17ed%2Fplainfields","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F0x5a17ed%2Fplainfields","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0x5a17ed%2Fplainfields/lists"}