<commit_before>extern crate config;
use self::config::types::{Config, ScalarValue, Value};

use std::env::home_dir;
use std::process::Command;

/// A command with arguments.
pub struct CommandLine {
    program: String,
    args: Vec<String>,
}

fn expand_home(path: &String) -> String {
    if path.starts_with("~/") {
        match home_dir() {
            Some(home) => format!("{}/{}", home.display(), &path[2..]),
            _ => path.clone(),
        }
    } else {
        path.clone()
    }
}

fn make_command_vec(vec: &Vec<Value>) -> Result<CommandLine, String> {
    if vec.is_empty() {
        return Err(format!("empty execution vector"));
    }

    let mut prog_args = vec![];
    for v in vec {
        match *v {
            Value::Svalue(ref sv) =>
                match *sv {
                    ScalarValue::Str(ref s) => prog_args.push(s),
                    _ => return Err(format!("non-string program value")),
                },
            _ => return Err(format!("non-string program value")),
        }
    }

    let (prog, args) = prog_args.split_at(1);
    Ok(CommandLine {
        program: expand_home(prog[0]),<commit_msg>exec: minor cleanup of expand_home<commit_after>extern crate config;
use self::config::types::{Config, ScalarValue, Value};

use std::env::home_dir;
use std::process::Command;

/// A command with arguments.
pub struct CommandLine {
    program: String,
    args: Vec<String>,
}

fn expand_home(path: &String) -> String {
    if path.starts_with("~/") {
        if let Some(home) = home_dir() {
            return format!("{}/{}", home.display(), &path[2..])
        }
    }

    path.clone()
}

fn make_command_vec(vec: &Vec<Value>) -> Result<CommandLine, String> {
    if vec.is_empty() {
        return Err(format!("empty execution vector"));
    }

    let mut prog_args = vec![];
    for v in vec {
        match *v {
            Value::Svalue(ref sv) =>
                match *sv {
                    ScalarValue::Str(ref s) => prog_args.push(s),
                    _ => return Err(format!("non-string program value")),
                },
            _ => return Err(format!("non-string program value")),
        }
    }

    let (prog, args) = prog_args.split_at(1);
    Ok(CommandLine {
        program: expand_home(prog[0]),
{'fraction_non_alphanumeric': 0.15952797202797203, 'fraction_numerical': 0.0026223776223776225, 'mean_word_length': 2.246808510638298, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 23, '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': '6759127', 'n_tokens_mistral': 728, 'n_tokens_neox': 708, 'n_words': 163}