Skip to content
/ BETTR Public

Boketto's Efficient TempleOS TOML Reader: Better manage TempleOS configs.

Notifications You must be signed in to change notification settings

tinkeros/BETTR

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

Boketto's Exquisite TempleOS TOML Reader

Welcome to BETTR; TempleOS's very first config reader!

With BETTR, you can easily read and modify configuration files written in TOML, thanks to its user-friendly interface and efficient implementation. This TOML reader is designed to be elegant and intuitive, making it a breeze to use for users of all skill levels.

I understand that your time is valuable, which is why BETTR is designed to make your life easier. With this config reader, you can quickly and easily modify configuration files without the need for extensive knowledge of HolyC or programming languages in general.

Why the Need for BETTR?

Managing configuration files is a crucial aspect of any developer's workflow. Configuration files offer a simpler way to modify variables and cases, making them a necessary component of any application. Configuration files can be used to store settings, options, and other data that your application or program needs to function properly. Without them, it can be challenging to keep track of different settings, leading to errors in your code. So, why doesn't TempleOS have config files yet?

BETTR was designed to benefit both developers and users. As a developer, BETTR offers a centralized suite for quickly modifying variables, sorted under sections and used appropriately. With BETTR, you no longer have to spend hours staring at convoluted code or learning a new programming language to make simple configuration changes. Instead, you can easily modify configuration files and focus on more critical aspects of your project.

BETTR's benefits extend beyond developers to users as well. With BETTR, users can quickly and easily modify configuration files from a centralized location, even if they lack knowledge of HolyC or programming languages. This makes BETTR a generous addition to any project, allowing developers to provide their users with an intuitive and user-friendly interface for modifying settings and options.

Usage

As of now, BETTR can be quite limited, however it is not difficult what-so-ever to implement it within your code.

Before we mess with any HolyC code, I'd like to provide a reference point. This is what the TOML file being used looks like:

[person1]
name = "John Doe"
age = 16

[person2]
name = "Jane Doe"
age = 39
  1. First and foremost, before you can do anything, you'll need to include the BETTR library within your project:

    #include "/Path/To/BETTR.HC"
  2. After that, you'll need to tell BETTR where it will be reading configs from:

    TOMLFile *toml_file = ReadTOMLFile("Path/To/Config.TOML");

    This will then load all of the configurations from your code as a single variable. Behind the scenes, this variable would looking something like:

    {
      {"person1", {"name", "John Doe"}, {"age", "16"}},
      {"person2", {"name", "Jane Doe"}, {"age", "39"}}
    }
  3. This is an optional step, but within your code, you should add some form of exception in case the config could not be read. This is not done through the library directly, in case it interfers with the program.

    if (toml_file) {
      // do something with the config    
    } else {
      "Failed to read TOML file.\n";
    }

    This code will will ensure that the toml_file variable was parsed correctly. Otherwise it will print your error message.

  4. You'll notice in the above code, I left a comment. That's because, what you do after this point is completely up to you!

    If you want, you could print out the contents of the file in a human readable format. You could get the value of a key. You could write into the file. It's up to you!

  5. At the end, always make sure to Free() the memory for everything. To help you out, the FreeTOML function exists, to free the total used memory:

    FreeTOML(toml_file);

Example Usage:

This code does not need much explanation if you have read the above notes.

U0 Bettr() {
    TOMLFile *toml_file = ReadTOMLFile("/Home/YumeSH/config.TOML"); // Shameless self-promotion.
    if (toml_file) {
        PrintTOMLContent(toml_file);
        FreeTOML(toml_file);
    } else {
        Print("Failed to read TOML file.\n");
    }
}

About

Boketto's Efficient TempleOS TOML Reader: Better manage TempleOS configs.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages