Skip to content

Commit

Permalink
Add Pigmnts CLI to crates.io
Browse files Browse the repository at this point in the history
  • Loading branch information
blenderskool committed Nov 9, 2020
1 parent f19a958 commit 6bcdb92
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 5 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,13 @@ jobs:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ matrix.asset_name }}.tar.gz
asset_name: ${{ matrix.asset_name }}.tar.gz
tag: ${{ github.ref }}
tag: ${{ github.ref }}

cli-publish:
needs: cli-test
name: CLI publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: cargo login ${{ secrets.CRATES_TOKEN }}
- run: cargo publish
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "pigmnts-cli"
version = "0.1.2"
authors = ["Akash Hamirwasia"]
edition = "2018"
description = "Generate a color palette from an image using WebAssesmbly"
description = "Generate a color palette from an image right on the command line"
license = "MIT"
readme = "README.md"
repository = "https://github.com/blenderskool/pigmnts.git"
Expand All @@ -14,7 +14,7 @@ image = "0.23.2"
spinners = "1.2.0"
termion = "1.5.5"
prettytable-rs = "0.8.0"
pigmnts = { path = "lib" }
pigmnts = { path = "lib", version = "0.6.0" }
reqwest = { version = "0.10", features = ["blocking"] }
serde_cbor = "0.11.1"
lazy_static = "^1.4.0"
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ Pigmnts CLI is a tool designed to create color palettes from an image right on y

Pigmnts CLI comes with various output modes and provides on-demand data of the palette generated while maintaining high speeds.

### Installing the CLI
CLI can be installed using `cargo` and `pigmnts-cli` crate on crates.io
```bash
cargo install pigmnts-cli
```


### Output modes

#### Default mode
Expand Down
4 changes: 3 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ extern crate serde_cbor;
extern crate serde_json;

use std::fs::File;
use std::env;

fn main() {
// This dataset has been taken from https://github.com/meodai/color-names
let color_names_file = File::open("./data/colornames.bestof.min.json").unwrap();
let color_names: serde_json::Value = serde_json::from_reader(color_names_file).unwrap();
let out_dir = env::var("OUT_DIR").unwrap();

let dest_file = File::create("./data/colornames.cbor").unwrap();
let dest_file = File::create(format!("{}/colornames.cbor", out_dir)).unwrap();
serde_cbor::to_writer(dest_file, &color_names).unwrap();
}
6 changes: 5 additions & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ fn hex_to_rgb(s: &str) -> RGB {

lazy_static! {
static ref COLOR_NAMES: (Vec<String>, Vec<LAB>) = {
let data: HashMap<String, String> = serde_cbor::from_slice(include_bytes!("../data/colornames.cbor")).unwrap();
let data: HashMap<String, String> = serde_cbor::from_slice(
include_bytes!(
concat!(env!("OUT_DIR"), "/colornames.cbor"))
).unwrap();

let values: Vec<LAB> = data
.iter()
.map(|(val, _)| LAB::from(&hex_to_rgb(val)))
Expand Down

0 comments on commit 6bcdb92

Please sign in to comment.