Giter VIP home page Giter VIP logo

gura's Introduction

Gura logo

Gura

Netlify Status

Gura is a file format for configuration files. Gura is as flexible as YAML and simple and readable like TOML. Its syntax is clear and powerful, yet familiar for YAML/TOML users:

This repository contains the source code of the Gura specification. You can find the released versions at https://gura.netlify.app/.

# This is a comment in a Gura configuration file.
# Define a variable named `title` with string value "Gura Example"
title: "Gura Example"

# Define an object with fields `username` and `age`
# with string and integer values, respectively
# Indentation is used to indicate nesting
person:
    username: "Stephen"
    age: 20

# Define a list of values
# Line breaks are OK when inside arrays
hosts: [
    "alpha",
    "omega"
]

# Variables can be defined and referenced to avoid repetition
$foreground: "#FFAH84"
color_scheme:
    editor: $foreground
    ui:     $foreground

The file extension for Gura is ura. We recommend the filename config.ura for main configuration files.

To learn more about Gura, you can read the Official Gura Documentation.

Currently, Gura has, among many others, a Python implementation you can install with pip install gura and start using today.

import gura

gura_string = """
title: "Gura Example"

person:
    username: "Stephen"
    age: 20

hosts: [
    "alpha",
    "omega"
]
"""

# Transforms in dictionary
parsed_gura = gura.loads(gura_string)

# Access a specific field
print(f"Title -> {parsed_gura['title']}")

# Access object data
person = parsed_gura['person']
print(f"My username is {person['username']}")

# Iterate over structure
for host in parsed_gura['hosts']:
    print(f'Host -> {host}')

Javascript/Typescript parser is also available! Check the complete implementation list to see available libraries. Other programming languages implementations are being currently developed and will be available shortly.

Index

Library implementations

Below is the list of implementations available for Gura. If you have an implementation of your own that you want to make known simply create a new issue and it will be added here.

IDE support

Below is the list of IDEs plugins available for Gura. If you have developed a plugin or IDE integration that you want to make known simply create a new issue and it will be added here.

Contributing

All help is more than welcome. You can:

  • Join to our community in Discord!
  • Write an RFC via our GitHub Discussions if you feel there is a bug in Gura or a missing feature.
  • Contribute to some of the implementations, or write your own in the programming language of your choice! In the latter case don't forget to make an issue letting us know that your implementation is available so we can add it to the Implementations list.

If you want to contribute with this website: it is built using Docusaurus 2, a modern static website generator.

Installation

yarn install

Local Development

yarn start

This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.

Build

yarn build

This command generates static content into the build directory and can be served using any static contents hosting service.

Rationale

Gura was born from the need to have a configuration language that is human readable without falling into the unnecessary complexity of popular formats such as YAML. The following is an overview of the issues with such formats, which motivated the creation of this new configuration language.

Differences with YAML

YAML offered a readable alternative to JSON or INI for a configuration file. While TOML was great for basic files because of its simplicity, YAML provided a readable solution when the complexity of the file grew. However, as the NOYAML manifesto argues, we should stop supporting that format. The reason? YAML is unnecessarily complex. We highlight main issues with YAML that Gura tries to solve.

  • Multiple different ways to define a list and the elements inside it
  • 4 (!) ways to define a boolean
  • Boolean automatically inferred from strings (workarounds)
  • Unnecessary unquoted strings that lead to float type inference problems
  • Serious security issues. Safe YAML attempts to address those, but only those.
  • Increadibly long YAML specs for what is supposed to be a simple configuration language?
  • Special data types such as Date or Datetime are defined in the spec, but the definition of their semantics is relegated to each specific implementation.

All the previous points lead to a difficult implementation in any programming language, it is enough to see the repositories of the different languages to realize that carrying out a YAML parser is a complicated task.

Differences with TOML

The idea of Gura is not to replace TOML, but to complement it when the complexity of the project warrants it. The use of TOML for files such as cargo.toml in the Rust programming language is an excellent example of matching the complexity of the language to that of the domain. However, when the level of nesting increases, TOML is very cumbersome since you must resort to repeating all the parent levels (using Dotted keys) every time you want to define a nested value.

Furthermore, even TOML falls in some cases into the same complexity as YAML, with features such as:

  • Multiple ways to specify keys
  • Empty keys
  • Special data types

Differences with JSON

JSON is and will be the fastest serialization language available. Gura is not meant for fast processing and/or machine-to-machine communication. When a readable, simple and maintainable language is needed Gura becomes an excellent alternative.

Gura

Gura combines the readability of YAML and a reduced version of its syntax with the (even more simplified) simplicity of TOML. It also brings in some features and characteristics exclusive to this language:

  • 📦 Variables: Gura allows you to define variables of any type, even using environment variables, both as a flat value and as values inside a string. So you can compact and reuse the values you require.
  • 📑 Imports: Gura defines a way to import different Gura files within the same file in order to modularize the configuration.
  • 🚫 Standard errors: Gura defines the semantic errors that should be thrown in certain situations. This way you get an implementation-agnostic definition and the developer can get the same type of error regardless of the programming language he/she is using.
  • 🥧 Gura is short and simple to learn and use, since it follows the only one way to do it Python maxim.
  • 🌈 Writing a parser or wrapper for Gura in a new language should be a short and simple as well.

Gura does not seek to replace the behavior that any programming language already offers in a much flexible and robust way. Therefore, it is limited to explicit static definitions that make it easier to understand both the language and the configuration files.

Gura will always be focused on simplicity. Therefore, we are reluctant to support more complex structures. If you are looking for a way to execute code like loops, conditions, functions and so on in a config file, we recommend Dhall.

Acknowledgements

I want to give my sincere thanks to Facundo Quiroga and Ulises Jeremias Cornejo Fandos for their guidance and valuable opinions during the design and implementation of Gura.

License

Gura is distributed under the terms of the MIT license.

gura's People

Contributors

dependabot[bot] avatar downloadpizza avatar facundoq avatar genarito avatar ulises-jeremias avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

gura's Issues

Avoid false binary input

If I were to have a value such as 0b0011 (a valid hex colour) what stops it being read as binary and just parsed as 3?

Invalid object keys

With #3 closed, there's only really one thing in the JSON data model that you can't represent in Gura, and that's objects with keys that don't conform to the normal requirements.

If Gura intetionally doesn't support this, then it might be a good idea to specify, as part of the spec, what generic serializers/deserializers should do when provided such keys, so that behaviour can be standardised.

eg.

  • Error.
  • Convert to a valid name according to some predefined rules.
  • Something else?

Gura parser for Dart

Hello! I have created a Gura parser for Dart and wanted to see if you'd like to add it to the list of implementations.

The source is available here:
https://github.com/zajrik/gura-dart-parser

and the package is available here:
https://pub.dev/packages/gura

This is largely a port of the official TypeScript parser but I've done a lot of cleaning up, refactoring, and internal documentation to help myself better understand the inner mechanics, as well as make some things work in Dart that can't translate directly from TS/JS.

I look forward to hearing from you.

Better recommended formatting for array of objects?

Consider this modified version of the example for arrays from https://gura.netlify.app/:

tango_singers: [
    name: "Carlos"
    surname: "Gardel"
    year_of_birth: 1890,
    name: "Aníbal"
    surname: "Troilo"
    year_of_birth: 1914
]

it contains two objects, but the comma is very easy to miss. If a comma is the only only way to split elements of an array, it might be better to recommend formatting arrays of objects like:

tango_singers: [
    name: "Carlos"
    surname: "Gardel"
    year_of_birth: 1890
    ,
    name: "Aníbal"
    surname: "Troilo"
    year_of_birth: 1914
]

`.gura` extension?

With other formats there is .json, .yaml/.yml and .toml. It was a bit odd to see .ura here, but I assume that's to provide a typical 3 char extension? Any reason to not support .gura?

Gura files should use the extension `.ura`.

.gura seems to fair better currently on google searches than .ura.


Although... I suppose .gura could be confused with a programming language called Gura too..:

The installer will set up all the necessary files as well as edit the registry to assign file extensions .gura, .guraw, .gurc and .gurcw as executable ones.

Still, .ura seems a bit odd 😅

Will the format also include .gura as a file extension, perhaps keeping preference to .ura if necessary? Or is more than one supported extension a concern you want to avoid?

Numeric object keys

serde_gura will serialize the following without question, but it will throw an error if you attempt to deserialize it:

resumable_shards:
    0:
        session_id: "xxxx"
        sequence: 2

It panics here.

Array trailing comma seems "mandatory"

Hello there and thanks for this good stuff !

The following snippet fails to parse, with "Expected end of string but got m at line 4 position 0".
If I add a trailing comma after last sub-array, all is fine.

Gura was installed via pip.

Could you please have a look ?

model:
    columns: [
        [ "var1", "str" ],
        [ "var2", "str" ]
    ]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.