DEV Community

aiocat
aiocat

Posted on

Best Way To Create Config Files

Hello folks! I made a config language 3 days ago to solve other language's problems. Now i wanted to share with you.

Problems

JSON

JSON is the most popular language to create configs. But JSON is not modern for 2021.

  • No Comment Support
  • Bad Syntax

TOML

TOML is another new config language and used by rust's cargo today. TOML solves some problems that JSON has but its still not simple to write.

YAML

YAML has same problems that TOML gives, not simple and fast to write.

XML

Everyone knows XML sucks for 2021.

Snug

And snug... Snug is created for write fast and simple configs with flexible syntax. For example:

num 1 str "Hello, World!"
Enter fullscreen mode Exit fullscreen mode

Lets convert this to the JSON:

{"num": 1, "str": "Hello, World!"}
Enter fullscreen mode Exit fullscreen mode

This is a valid snug file but it looks bad right? Let's fix the syntax:

# This is a simple comment, comments are starting with a hashtag and continues until next hashtag. #

num 1
str "Hello, World!"
Enter fullscreen mode Exit fullscreen mode

Say goodbye to indentation syntax, semicolons and if you want to write worst syntax, new lines.

Snug also supports object and arrays. Time to give a complex example:

# This is a comment! #
title "Hello World"
views 4826
is-public yes
owners ["User1" "User2"] # This is an array. #

(content # This is an object. #
text "Hello everyone, how are you?"
sha256-hash "0cfb86e2b382029d9c7ee32e98f855c1e870b688766da19caee32122894db03b"
color 12648430)

allow-edit no
Enter fullscreen mode Exit fullscreen mode

Learning

Libraries

Snug has language support problem right now. Only supports Vanilla JavaScript and Python3 (28/11/2021) for now. For contributing to this project, You can create snug libraries for other languages. Also after publishing your library, You can create merge request on GitLab repository to add your library to libraries list.

Click for snug libraries.

Top comments (0)