Misterio77 / flavours

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

Create a new `pub fn` wrapper to expose `fn build_template` via the cli #32

Closed RichardBronosky closed 3 years ago

RichardBronosky commented 3 years ago

Proposed interface:

    .subcommand(
        App::new("build")
            .about("Builds template with given scheme, outputs to stdout")
            .setting(AppSettings::UnifiedHelpMessage)
            .setting(AppSettings::DeriveDisplayOrder)
            .setting(AppSettings::DisableHelpSubcommand)
            .setting(AppSettings::DisableVersion)
            .setting(AppSettings::ColoredHelp)
            .arg(
                Arg::new("scheme")
                .about("Path to scheme file.")
                .long("scheme")
                .short('s')
                .required(true)
                .value_hint(ValueHint::FilePath)
            )
            .arg(
                Arg::new("template")
                .about("Path to template file.")
                .long("template")
                .short('t')
                .required(true)
                .value_hint(ValueHint::FilePath)
            )
    )

I got the feeling that I could implement this, even though I've never done Rust, by looking at:

Would you be open to this if I submitted a PR?

RichardBronosky commented 3 years ago

It would really help if you had some tests I could run on my code to validate it.

Misterio77 commented 3 years ago

Hey, nice suggestion.

I would be open for sure.

The code is a bit of a mess (my first rust project, and i was kinda rushing the features instead of bothering with correctness and modularity), so the code is not really unit testable right now. I can provide you with some integrations tests, if you need.

I can get this working kinda quickly, too, if you prefer

Misterio77 commented 3 years ago

Would you rather the cli arguments be actual scheme and template files, or just the name slugs located on .local/share/flavours (as most other commands work)?

RichardBronosky commented 3 years ago

I get what you are saying about the name slugs. My goal was to correct the issue where every project listed at https://github.com/chriskempson/base16#builder-repositories seems abandoned. https://github.com/base16-builder/base16-builder/issues/174 and therefore there is no decent docker container https://hub.docker.com/r/mindfulmonk/base16-builder-docker that can be used to unit test PRs to other templates like https://github.com/chriskempson/base16-shell and https://github.com/chriskempson/base16-vim

As you can see [for me] this is actually a multi-layered issue. If I can make Flavours work as a stand-alone builder, I think it could be the de-facto base16 toolchain.

So, yes, I understand why you want to use the files in the $FLAVOURS_DATA_DIRECTORY, I can include that as --scheme and --template, but I would also want to include options that are mutually exclusive to those for --scheme-file and --template-file so that the build cli subcommand can be used even if update has never been called.

Does that work for you?

Misterio77 commented 3 years ago

Sure does

Misterio77 commented 3 years ago

I'm working on a rewrite (on small steps, kinda busy in the last few months), and i should include this feature when i'm done with it, but will probably take a few months still. Until then, please feel free to write the feature, let me know if you need any help.

Misterio77 commented 3 years ago

Well, i've come across something i was working on that would be absolutely benefited by this, so i took a dive into the code again and ended up implementing this subcommand.

I'll push this to master so you can test it, then please let me know if it works as you intended, so i can release a new version :))

RichardBronosky commented 3 years ago

I will check this out today. Here is something I've been working on. https://hub.docker.com/r/richardbronosky/base16-builder-go I'd like to replace the binary inside with flavours.

RichardBronosky commented 3 years ago

It's a thing of beauty!


bruno@BrunoMBP1 flavours % cd src
bruno@BrunoMBP1 src % cargo build

   Compiling flavours v0.4.0 (/Users/bruno/src/flavours)
    Finished dev [unoptimized + debuginfo] target(s) in 4.81s

bruno@BrunoMBP1 src % scheme_url='https://github.com/chriskempson/base16-default-schemes/raw/daf67429/ocean.yaml'
bruno@BrunoMBP1 src % template_url='https://github.com/chriskempson/base16-shell/raw/ced506b6/templates/default.mustache'
bruno@BrunoMBP1 src % curl -sLo /tmp/scheme.yaml  $scheme_url
bruno@BrunoMBP1 src % curl -sLo /tmp/template     $template_url

bruno@BrunoMBP1 src %  ../target/debug/flavours build /tmp/scheme.yaml /tmp//tmp/template | head
#!/bin/sh
# base16-shell (https://github.com/chriskempson/base16-shell)
# Base16 Shell template by Chris Kempson (http://chriskempson.com)
# Ocean scheme by Chris Kempson (http://chriskempson.com)

color00="2b/30/3b" # Base 00 - Black
color01="bf/61/6a" # Base 08 - Red
color02="a3/be/8c" # Base 0B - Green
color03="eb/cb/8b" # Base 0A - Yellow
color04="8f/a1/b3" # Base 0D - Blue

This is a great feature. Excellent work!

Misterio77 commented 3 years ago

Thanks a lot for the feedback, glad it worked out for you!