tinted-theming / tinted-shell

Base16 and Base24 for Shells
https://github.com/tinted-theming/home
MIT License
65 stars 217 forks source link

Rust cli tool #39

Closed JamyGolden closed 8 months ago

JamyGolden commented 1 year ago

I want to learn Rust and since I work on the base16-shell profile_helper.sh and hook scripts fairly often; I thought it might be nice to have something more robust while also learning Rust 😊 Any nitpicks are welcome since I don't know what are good practices and what aren't, etc :sweat_smile:

At this point there are so many commits here it's essentially a way of commenting on a branch, so it might be easier to have a look at the branch over the "Files changed" tab, not sure: https://github.com/tinted-theming/base16-shell/tree/jamy/feature/rust-shell/src

Usage

Overview of the tool

❯ base16-shell --help
A tool to switch base16 colorschemes

Usage: base16-shell [OPTIONS] [COMMAND]

Commands:
  list  Lists available base16 colorschemes
  set   Sets a base16 colorscheme
  help  Print this message or the help of the given subcommand(s)

Options:
  -d, --repo-dir <DIR>  Optional path to the base16-shell repository. This is used to run the colorschemes and hooks if you don't want to use the compiled versions.
  -h, --help            Print help
  -V, --version         Print version

Basic usage

Compiled usage

cargo build will generate a binary at ./target/debug/base16-shell. So cargo build && ./target/debug/base16-shell list should generate a list of available themes for example.

Usage with the the --repo-dir option

This allows users to have the cli tool to use their own local base16-shell repo. This can be useful for when you work on base16-shell so you don't need to compile the cli tool every time you do a template or hook change. By default the hooks and the colorscheme scripts are embedded and used by cli tool, but when you pass in --repo-dir it doesn't use the embedded content.

Todo

I'm looking into writing tests now.

JamyGolden commented 1 year ago

@belak The profile_helper.sh part of base16-shell is really a "manager" concept and not template related at all. Esp since it deals with base16-tmux, base16-fzf, base16-vim, etc in the hooks. It may be better to create a new repo for this so it doesn't live with the shell templates and colorschemes. What do you think?

I'm not sure how to distribute the binaries. I had a look at builder-go, but still not really sure how the binaries to download are put under "releases".

I haven't written tests yet. I'll do that once we're happy with everything and before I merge.

JamyGolden commented 11 months ago

Sorting out a few more bugs, but I feel like it's pretty solid now. It now has an optional flag --repo-dir which accepts a path to your local base16-shell directory. With that provided, when you run base16-shell list and base16-shell set ocean it will execute your local base16-shell/scripts and base16-shell/hooks. If you don't use the argument, it will use the scripts and hooks that existed at compile time. Still haven't added tests yet though.

JamyGolden commented 11 months ago

Added integration tests

JamyGolden commented 8 months ago

Closing this PR since development has moved to https://github.com/tinted-theming/tinty