packages/Chatdown/bin/chatdown.js
async function runProgram() {
    const args = minimist(process.argv.slice(2));

    if (args.prefix) {
        intercept(function(txt) {
            return `[${pkg.name}]\n${txt}`;
        });
    }

    let latest = await latestVersion(pkg.name, { version: `>${pkg.version}` })
                        .catch(error => pkg.version);
    if (semver.gt(latest, pkg.version)) {
        process.stderr.write(chalk.default.white(`\n     Update available `));
        process.stderr.write(chalk.default.grey(`${pkg.version}`));
        process.stderr.write(chalk.default.white(` -> `));
        process.stderr.write(chalk.default.greenBright(`${latest}\n`));
        process.stderr.write(chalk.default.white(`     Run `));
        process.stderr.write(chalk.default.blueBright(`npm i -g ${pkg.name} `));
        process.stderr.write(chalk.default.white(`to update.\n`));
    }

    if (args.version || args.v) {
        process.stdout.write(pkg.version);
        return 0;
    }

    if (args.h || args.help) {
        help(process.stdout);
        return 0;
    }

    if (args.f || args.folder) {
        let inputDir = args.f.trim();
        let outputDir = (args.o || args.out_folder) ? args.o.trim() : "./";
        if (outputDir.substr(0, 2) === "./") {
            outputDir = path.resolve(process.cwd(), outputDir.substr(2))
        }
        const len = await processFiles(inputDir, outputDir);
        process.stdout.write(chalk`{green Successfully wrote ${len} files}\n`);
        return len;
    }
    else {
        const fileContents = await getInput(args);
        if (fileContents) {
            const activities = await chatdown(fileContents, args);
            const writeConfirmation = await writeOut(activities, args);

            if (typeof writeConfirmation === 'string') {
                process.stdout.write(chalk`{green Successfully wrote file:} {blue ${writeConfirmation}}\n`);
            }
            return 0;
        }
        else {
            help();
            return -1;
        }
    }
}
async function runProgram() {
    const args = minimist(process.argv.slice(2));

    if (args.prefix) {
        intercept(function(txt) {
            return `[${pkg.name}]\n${txt}`;
        });
    }

    let latest = await latestVersion(pkg.name, { version: `>${pkg.version}` })
                        .catch(error => pkg.version);
    if (semver.gt(latest, pkg.version)) {
        process.stderr.write(chalk.default.white(`\n     Update available `));
        process.stderr.write(chalk.default.grey(`${pkg.version}`));
        process.stderr.write(chalk.default.white(` -> `));
        process.stderr.write(chalk.default.greenBright(`${latest}\n`));
        process.stderr.write(chalk.default.white(`     Run `));
        process.stderr.write(chalk.default.blueBright(`npm i -g ${pkg.name} `));
        process.stderr.write(chalk.default.white(`to update.\n`));
    }

    if (args.version || args.v) {
        process.stdout.write(pkg.version);
        return 0;
    }

    if (args.h || args.help) {
        help(process.stdout);
        return 0;
    }

    if (args.f || args.folder) {
        let inputDir = args.f.trim();
        let outputDir = (args.o || args.out_folder) ? args.o.trim() : "./";
        if (outputDir.substr(0, 2) === "./") {
            outputDir = path.resolve(process.cwd(), outputDir.substr(2))
        }
        const len = await processFiles(inputDir, outputDir);
        process.stdout.write(chalk`{green Successfully wrote ${len} files}\n`);
        return len;
    }
    else {
        const fileContents = await getInput(args);
        if (fileContents) {
            const activities = await chatdown(fileContents, args);
            const writeConfirmation = await writeOut(activities, args);

            if (typeof writeConfirmation === 'string') {
                process.stdout.write(chalk`{green Successfully wrote file:} {blue ${writeConfirmation}}\n`);
            }
            return 0;
        }
        else {
            help();
            return -1;
        }
    }
}
async function runProgram ( ) { const args = minimist ( process . argv . slice ( 2 ) ) ; if ( args . prefix ) { intercept ( function ( txt ) { return ` ${ pkg . name } \n ${ txt } ` ; } ) ; } let latest = await latestVersion ( pkg . name , { version : ` ${ pkg . version } ` } ) . catch ( error => pkg . version ) ; if ( semver . gt ( latest , pkg . version ) ) { process . stderr . write ( chalk . default . white ( ` \n ` ) ) ; process . stderr . write ( chalk . default . grey ( ` ${ pkg . version } ` ) ) ; process . stderr . write ( chalk . default . white ( ` ` ) ) ; process . stderr . write ( chalk . default . greenBright ( ` ${ latest } \n ` ) ) ; process . stderr . write ( chalk . default . white ( ` ` ) ) ; process . stderr . write ( chalk . default . blueBright ( ` ${ pkg . name } ` ) ) ; process . stderr . write ( chalk . default . white ( ` \n ` ) ) ; } if ( args . version || args . v ) { process . stdout . write ( pkg . version ) ; return 0 ; } if ( args . h || args . help ) { help ( process . stdout ) ; return 0 ; } if ( args . f || args . folder ) { let inputDir = args . f . trim ( ) ; let outputDir = ( args . o || args . out_folder ) ? args . o . trim ( ) : "./" ; if ( outputDir . substr ( 0 , 2 ) === "./" ) { outputDir = path . resolve ( process . cwd ( ) , outputDir . substr ( 2 ) ) } const len = await processFiles ( inputDir , outputDir ) ; process . stdout . write ( chalk ` ${ len } \n ` ) ; return len ; } else { const fileContents = await getInput ( args ) ; if ( fileContents ) { const activities = await chatdown ( fileContents , args ) ; const writeConfirmation = await writeOut ( activities , args ) ; if ( typeof writeConfirmation === 'string' ) { process . stdout . write ( chalk ` ${ writeConfirmation } \n ` ) ; } return 0 ; } else { help ( ) ; return - 1 ; } } }
Runs the program

@returns {Promise<void>}
Runs the program