<commit_before>import {
    QuickCommandType,
    CommandType,
    CommandTypeList,
    InputInterface,
    OutputInterface,
    CommandInterface
} from '../interfaces';

import {resolve} from 'path';
import {toString} from './helper';

function requireCommand(path: string): CommandInterface {

    let [file, name] = path.split('#');
    let filepath = file[0] === '.' ?
        resolve(file) :
        require.resolve(file);

    let command: CommandInterface | QuickCommandType = name ?
        require(filepath)[name] :
        require(filepath);

    if (typeof command === 'function') {
        return new QuickCommandProxy(<QuickCommandType>command);

    } else if (Object(command) === command) {
        return <CommandInterface>command;

    } else {
        throw new Error(
            'Unexpected command type resolve: ' + path +
            ' must be a funtion|object instance instead of ' + toString(command)
        );
    }
}

/**
 * StringCommandProxy
 */
export class StringCommandProxy implements CommandInterface {

    _path: string;

    _command: CommandInterface;

    constructor(path: string) {<commit_msg>imporve error message<commit_after>import {
    QuickCommandType,
    CommandType,
    CommandTypeList,
    InputInterface,
    OutputInterface,
    CommandInterface
} from '../interfaces';

import {resolve} from 'path';
import {toString} from './helper';

function requireCommand(path: string): CommandInterface {

    let [file, name] = path.split('#');
    let filepath = file[0] === '.' ?
        resolve(file) :
        require.resolve(file);

    let command: CommandInterface | QuickCommandType = name ?
        require(filepath)[name] :
        require(filepath);

    if (typeof command === 'function') {
        return new QuickCommandProxy(<QuickCommandType>command);

    } else if (Object(command) === command) {
        return <CommandInterface>command;

    } else if (name && command === undefined) {
        throw new Error(name + ' not found in ' + path);
        
    } else {
        throw new Error(
            'Unexpected command type resolve: ' + path +
            ' must be a funtion|object instance instead of ' + toString(command)
        );
    }
}

/**
 * StringCommandProxy
 */
export class StringCommandProxy implements CommandInterface {

    _path: string;

    _command: CommandInterface;

    constructor(path: string) {
{'fraction_non_alphanumeric': 0.11631799163179916, 'fraction_numerical': 0.0008368200836820083, 'mean_word_length': 2.8689320388349513, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5962677', 'n_tokens_mistral': 648, 'n_tokens_neox': 629, 'n_words': 172}