matryer / xbar

Put the output from any script or program into your macOS Menu Bar (the BitBar reboot)
https://xbarapp.com
MIT License
17.59k stars 642 forks source link

Feature request: Re-create/edit *.vars.json file if invalid #719

Open The-Michael-R opened 3 years ago

The-Michael-R commented 3 years ago

Hi, I managed to create an invalid vars file (removing obsolete variables, forgot to remove the comma at the last variable). I got an error message in the "Open Plugin..." screen complaining about the error.

An option to 'Fix' the *.vars.json file by create a clean new file would be helpful to get a user friendly recovery. Of course with a reasonable warning that this will reset the variables. The option to to manually edit the file would be nice too.

Probably a warning or message about the invalid vars file in the xbar-menu line would be nice too. Currently it just don't work as expected.

And: Thanks for the great tool!

matryer commented 3 years ago

@The-Michael-R thanks for this - what does the error look like? I love the idea of a user friendly recovery for this, if you fancy doing a PR? :)

The-Michael-R commented 3 years ago

@matryer In my case the vars-file looked like:

{
        "VAR_IP": "127.0.0.1",
        "VAR_MAC": "42:42:42:42:42:42",
}

please note the "," after the VAR_MAC address. Now going to xbar->Open Plugin... it looks like that: image (eventually a refresh is required). And of course the plugin stopped to work. Xbar still looks like it's working, but no action happens: image Any notice that there's something wrong would be helpful. Even is that's just a warning sign.

About the PR: I would be happy to provide some code but that would be my first hands on to Go (I'm more a plain C coder) and alone figure out where to start might take some time.

matryer commented 3 years ago

@The-Michael-R That's a great report, thank you. I'll have a look at this. I suspect there may even be a JavaScript element to solving this one too; essentially, errors shouldn't crash things.