Repository

treevee

is a V implementation of a parser for the tree format

This is the WIP (work in progress) to provide v support for the tree format of the $mol frontend framework . Use it like this:

import koplenov.treevee

fn main() {
    treeveee.Tree.from_string("simple_config") or { panic(err) }
}

Installing

  • Using vpm: v install koplenov.treevee

Usage

Select values:

tree := treeve.Tree.from_string_file("./tests/example_1.tree") or { panic(err) }

// integer
assert tree.value("port").int() == 8079

// string
assert tree.value("port").text() == "8079"
assert tree.value("database_root_password").text() == ""
assert tree.value("default_htaccess").text() == ".htaccess"
assert tree.value("server_name").text() == "default server name"

Select nested values:

tree := treeve.Tree.from_string_file("./tests/example_2.tree") or { panic(err) }

assert tree.select("server", "auth").kids[0].kids.len == 2
assert tree.value("server", "auth", "login").text() == "root"
assert tree.value("server", "auth", "password").text() == "qwerty"

Select arrays:

tree := treeve.Tree.from_string_file("./tests/example_3.tree") or { panic(err) }
// of strings
assert tree.value("user","hobby").array() == ['kendo', 'dance', 'role play']

// of numbers
assert tree.value("user","loved_numbers").array_int() == [7, 21, 42]

About

Library for working with the .tree format.

0
4
6 days ago

Author

koplenov