File: convert.rs

package info (click to toggle)
rust-ansi-colours 1.2.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 212 kB
  • sloc: makefile: 2
file content (22 lines) | stat: -rw-r--r-- 689 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
extern crate ansi_colours;

use ansi_colours::*;

fn main() {
    let args: Vec<String> = std::env::args().collect();
    if args.len() == 2 {
        let index = args[1].parse::<u8>().unwrap();
        println!("{:-3}: {:?}", index, rgb_from_ansi256(index));
    } else if args.len() == 4 {
        let rgb = (
            args[1].parse::<u8>().unwrap(),
            args[2].parse::<u8>().unwrap(),
            args[3].parse::<u8>().unwrap(),
        );
        let index = ansi256_from_rgb(rgb);
        println!("{:?} ~ {:-3} {:?}", rgb, index, rgb_from_ansi256(index));
    } else {
        eprintln!("usage: convert ( <index> | <r> <g> <b> )");
        std::process::exit(1);
    }
}