<commit_before>extern crate hetu;

use hetu::Ssn;
use hetu::SsnPattern;
use hetu::ParseError;
use hetu::ErrorIndexRange;
use std::env;
use std::process;

pub fn main() {
    let args: Vec<String> = env::args().skip(1).collect();
    if args.len() > 1 && &args[0] == "-p" {
        match SsnPattern::parse(&args[1]) {
            Err(ref err) => {
                eprintln!("Error: {}\n\n  {}\n  {}", err, &args[1], index_arrows(err));
                process::exit(1)
            }
            Ok(pattern) => println!("{}", Ssn::generate_by_pattern(&pattern))
        }
    } else if args.len() == 0 {
        let pattern = SsnPattern::new();
        println!("{}", Ssn::generate_by_pattern(&pattern));
    } else {
        let ssn: &String = &args[0];
        match Ssn::parse(&ssn) {
            Ok(_) => (),
            Err(ref err) => {
                eprintln!("Error: {}\n\n  {}\n  {}", err, &ssn, index_arrows(err));
                process::exit(1)
            }
        }
    }
}

fn index_arrows(err: &ParseError) -> String {<commit_msg>Add help message to CLI<commit_after>extern crate hetu;

use hetu::Ssn;
use hetu::SsnPattern;
use hetu::ParseError;
use hetu::ErrorIndexRange;
use std::env;
use std::process;

pub fn main() {
    let args: Vec<String> = env::args().skip(1).collect();
    if args.len() == 0 || &args[0] == "-h" || &args[0] == "--help" {
        println!("Validator and generator for Finnish SSN

Usage:
    hetu <ssn>
    hetu -p <pattern>
    hetu [options]

Options:
    -h, --help          Display this message
");
        return
    }
    if args.len() > 1 && &args[0] == "-p" {
        match SsnPattern::parse(&args[1]) {
            Err(ref err) => {
                eprintln!("Error: {}\n\n  {}\n  {}", err, &args[1], index_arrows(err));
                process::exit(1)
            }
            Ok(pattern) => println!("{}", Ssn::generate_by_pattern(&pattern))
        }
    } else if args.len() == 0 {
        let pattern = SsnPattern::new();
        println!("{}", Ssn::generate_by_pattern(&pattern));
    } else {
        let ssn: &String = &args[0];
        match Ssn::parse(&ssn) {
            Ok(_) => (),
            Err(ref err) => {
                eprintln!("Error: {}\n\n  {}\n  {}", err, &ssn, index_arrows(err));
                process::exit(1)
            }
        }
    }
}

fn index_arrows(err: &ParseError) -> String {
{'fraction_non_alphanumeric': 0.19310054690786707, 'fraction_numerical': 0.008834665544804375, 'mean_word_length': 2.10443864229765, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1617020', 'n_tokens_mistral': 825, 'n_tokens_neox': 813, 'n_words': 174}