Misterio77 / flavours

🎨💧 An easy to use base16 scheme manager that integrates with any workflow.
MIT License
501 stars 29 forks source link

info fails to parse non-existent scheme #47

Open pcgjerde opened 2 years ago

pcgjerde commented 2 years ago

Hi,

I recently started getting an error when trying to run flavours info. After listing a few schemes it gives the following error:

Error: Couldn't parse scheme toast. Check if it's syntatically correct.

Caused by:
    missing field `scheme` at line 1 column 6

This seems especially odd to me since as far as I can tell there is no theme named 'toast' in Base16, and the next theme alphabetically should be "classic". have tried deleting ~/.local/share/flavours and running flavours update all, but I still get the same error.

I am still able to use the other subcommands as expected.

Misterio77 commented 2 years ago

Hey, thanks for reporting this!

It seems base16-circus introduced a CI file (named toast.yml): https://github.com/stepchowfun/base16-circus-scheme... Sigh

Flavours can't possibly know this is not supposed to be parsed as a scheme (as we currently consider anything *.y{a,}ml to be one).

I really dislike base16's fragmentation and impossibility of tracking changes. I mean, why would a scheme possibly need CI?

Well, as to your issue. You can either delete schemes/circus/toast.yml, or remove base16-circus from sources/schemes/list.yaml. I'll probably have to hardcode this to be deleted when update is ran.

pcgjerde commented 2 years ago

Thanks, deleting that file fixed the problem. I think it would be a good idea to let info.rs fail gracefully if it finds an invalid scheme file. This is a really gross hack, but something like this on line 80 in info.rs would allow you to skip over invalid scheme files and preserve an error message:

let scheme;
match Scheme::from_str(&scheme_contents, scheme_slug) {
            Ok(t) => scheme = t,
            Err(e) => {
                eprintln!("Error: {}", e);
                eprintln!();
                eprintln!("Caused by:");
                e.chain().skip(1).for_each(|cause| eprintln!("    {}", cause));
                continue;
            }
        };

There's probably a better way to do this, but it does build.