Configuration format change

As prevously discussed here, we need to switch from YML to something else … best shot so far is toml.

cc @dadav

2 Likes

As an overall dummy and not a programmer (yet) toml seems pretty good for being easier to use than yaml and causes less issues with tabs and spaces, so i would probably prefer toml.

1 Like

agreed, so far it seems the best candidate

1 Like

While we are on the topic can we discuss the possibility of breaking the config out into a main config and a directory of smaller configs for the plugins? Maybe something like pwnagotchi.cfg for the main config and any plugin specific stuff that’s been added be the community would go into something like a pwnagotchi.d/pluginnamehere.cfg

2 Likes

yes that sounds like a very good idea … @dadav does toml support an include system?

2 Likes

I’m afraid that the ML in TOML means minimal language. There is no include statement^^

but we can easily merge the configs ourselfs. We already have the function for that in utils.py

1 Like

Most editors have packages you can install to make editing yml files less painful… I’m probably in the minority here but use emacs with the elpa-yaml-mode package. It helped me a lot when I started messing around with ansible.

@Maxamis You are right, I’m sure @evilsocket also uses an IDE which supports that. But the fact that we need a plugin to comfortly read the config speaks for itself^^

1 Like

@dadav While I think @Maxamis solution is less than elegant I still think hes got a good idea there even if I dont agree with the conclusion. Whatever language we choose to go with for the config we will still need to be able to parse the config in the main pwnagotchi program before loading its values. If only just to validate that the config is syntactically correct then error out with a descriptive error of the problem if there is one.

Have we considered hjson (not a typo) at this point?

The pros are

  • its already got support on python
  • it dosn’t have to rely on whitespace usage in its current form
  • there are all kinds of parsers and validators out there for it if we make the simple step to convert a config to json

Cons would be we would need to rewrite how the pwnagotchi loads that which is something we would have to do anyway.

i’m reading the docs and to be honest it looks pretty cool

hjson also looks nice^^

But i still prefer toml, because i like:

main.plugins.bt-tether.enabled: true

better than

{
    main:
   {
        plugins:
        {
           bt-tether:
           {
             enabled: true
           }
       }
   }
}

but maybe thats just personal preference.

3 Likes

@dadav that’s fair just throwing shit at the wall and seeing what sticks over here

2 Likes

It’s a good suggestion^^

1 Like

I think the problem with Hjson may be it’s ambiguity.

Because it is meant to be HUMANreadable json, I think this will produce:

  • more ambiguities,
  • more styles of configurations files (for plugins, etc) and
  • will (potentially) eventually increase the number of related issues around configuration.

A format that is more standardized(?) + has a bit more strictly defined structure, in my opinion will reduce issues and errors like this in the future.

j’adore TOML, aussi.

2 Likes

yeah so far TOML seems the best solution

2 Likes

so, lets do it? :smiley:

we need some migration process of cause! Something like:

If toml-file not found -> parse legacy -> save as toml

on the next run, it will use toml

done

1 Like