Giter VIP home page Giter VIP logo

dipc's People

Contributors

adtya avatar cordlesscoder avatar doprz avatar sh-koh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

dipc's Issues

Compiling from source return errors

  Compiling dipc v0.5.0 (/home/rochalaj/dipc)
warning: unused imports: `fs::File`, `io::BufReader`
 --> src/cli.rs:1:11
  |
1 | use std::{fs::File, io::BufReader, path::PathBuf, str::FromStr};
  |           ^^^^^^^^  ^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: unused import: `serde_json::Value`
 --> src/cli.rs:4:5
  |
4 | use serde_json::Value;
  |     ^^^^^^^^^^^^^^^^^

error[E0599]: no variant named `RawJSON` found for enum `ColorPalette`
   --> src/config.rs:151:23
    |
151 |         ColorPalette::RawJSON { .. } => String::new(),
    |                       ^^^^^^^ variant not found in `ColorPalette`
    |
   ::: src/cli.rs:107:1
    |
107 | pub enum ColorPalette {
    | --------------------- variant `RawJSON` not found here

error[E0277]: `ColorPaletteArgGroup` doesn't implement `std::fmt::Display`
  --> src/main.rs:53:13
   |
53 |             cli.color_palette, cli.styles
   |             ^^^^^^^^^^^^^^^^^ `ColorPaletteArgGroup` cannot be formatted with the default formatter
   |
   = help: the trait `std::fmt::Display` is not implemented for `ColorPaletteArgGroup`
   = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
   = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `writeln` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0599]: no method named `clone` found for struct `ColorPaletteArgGroup` in the current scope
  --> src/main.rs:60:58
   |
60 |     let palettes = match parse_palette(cli.color_palette.clone().get_json(), &cli.styles) {
   |                                                          ^^^^^ method not found in `ColorPaletteArgGroup`
   |
  ::: src/cli.rs:45:1
   |
45 | struct ColorPaletteArgGroup {
   | --------------------------- method `clone` not found for this struct
   |
   = help: items from traits can only be used if the trait is implemented and in scope
   = note: the following trait defines an item `clone`, perhaps you need to implement it:
           candidate #1: `Clone`

error[E0308]: mismatched types
   --> src/main.rs:162:50
    |
162 |             let new_rgb = lab.to_nearest_palette(&palettes).to_rgb();
    |                               ------------------ ^^^^^^^^^ expected `&[Lab]`, found `&Vec<Palette>`
    |                               |
    |                               arguments to this method are incorrect
    |
    = note: expected reference `&[delta::Lab]`
               found reference `&Vec<Palette>`
note: method defined here
   --> src/delta.rs:35:12
    |
35  |     pub fn to_nearest_palette(self, palette: &[Lab]) -> Self {
    |            ^^^^^^^^^^^^^^^^^^       ---------------

error[E0308]: mismatched types
   --> src/main.rs:166:56
    |
166 |         let output_file_name = output_file_name(&path, &cli.color_palette, &palettes);
    |                                ----------------        ^^^^^^^^^^^^^^^^^^ expected `&ColorPalette`, found `&ColorPaletteArgGroup`
    |                                |
    |                                arguments to this function are incorrect
    |
    = note: expected reference `&ColorPalette`
               found reference `&ColorPaletteArgGroup`
note: function defined here
   --> src/config.rs:137:8
    |
137 | pub fn output_file_name(
    |        ^^^^^^^^^^^^^^^^
138 |     input_file_path: &PathBuf,
139 |     color_palette: &ColorPalette,
    |     ----------------------------

Some errors have detailed explanations: E0277, E0308, E0599.
For more information about an error, try `rustc --explain E0277`.
warning: `dipc` (bin "dipc") generated 2 warnings
error: could not compile `dipc` due to 5 previous errors; 2 warnings emitted
error: failed to compile `dipc v0.5.0 (/home/rochalaj/dipc)`, intermediate artifacts can be found at `/home/rochalaj/dipc/target`

cargo v1.69.0
OpenSuse Tumbleweed

how to reproduce

  1. git clone https://github.com/doprz/dipc.git
  2. cd dipc
  3. cargo install --path .

I did not obtain any kind of error installing directly from cargo with: cargo install dipc

use of unstable library feature 'is_some_and'

Compiling after merging PR #1 causes this error at src/main.rs:93:10
use of unstable library feature 'is_some_and'

// Print palettes
let color = supports_color::on_cached(supports_color::Stream::Stdout)
    .is_some_and(|level| level.has_16m);

Move to Indicatif

I suggest replacing the custom timing code and print statements with an indicatif-based Statusbar

  • Statusbar for loading & processing themes
  • Statusbar for processing each image

Add `ColorPaletteArgGroup`

  • Add ColorPaletteArgGroup to Cli.
  • Separate choosing one of: color_palette, json_file, or raw_json for easier CLI usage.
  • Refactor code to add Cli args + features:
    • json_file
    • raw_json
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
pub struct Cli {
    // Options
    /// The color palette variation(s) to use
    /// Run with --help instead of -h for a list of all possible values
    ///
    /// Possible values:
    /// - `all` to generate an image for each of the variations
    /// - `none` if you are using a flat theme without variations
    /// - or a comma-delimited list of the names of variations it should use
    #[arg(
        short,
        long,
        value_name = "VARIATIONS",
        default_value = "all",
        verbatim_doc_comment
    )]
    pub styles: ColorPaletteStyles,

    /// Output directory
    #[arg(short, long, value_name = "PATH", default_value = "output")]
    pub output: PathBuf,

    /// Verbose mode (-v, -vv, -vvv)
    #[arg(short, long, action = clap::ArgAction::Count)]
    pub verbose: u8,

    // Arguments
    #[command(flatten)]
    pub color_palette: ColorPaletteArgGroup,

    /// The image(s) to process
    #[arg(value_name = "FILE")]
    pub process: Vec<PathBuf>,
}
#[derive(Args, Debug)]
#[group(required = true, multiple = false)]
struct ColorPaletteArgGroup {
    /// The color palette to use
    /// Run with --help instead of -h for a list of all builtin themes
    ///
    /// Builtin themes:
    /// - catppuccin
    /// - edge
    /// - everforest
    /// - gruvbox
    /// - gruvbox-material
    /// - nord
    /// - rose-pine
    /// - tokyo-night
    #[arg(short, long, value_enum, verbatim_doc_comment)]
    pub color_palette: ColorPalette,

    /// The path to a JSON file with the color palette
    #[arg(short, long)]
    pub json_file: PathBuf,

    /// A JSON string with the color palette (starting with `JSON: {}`)
    #[arg(short, long)]
    pub raw_json: String,
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.