#!/usr/bin/env node; /****************************************************************************** * This program prints a message over and over. * Takes arguments from the command line. * First argument is number of times to print. * Second argument is the message to print (use double quotes) * * Copyright © 2020 Richard Lesh. All rights reserved. *****************************************************************************/ const Utils = require('./Utils'); const REPEATS = 100; const MESSAGE = "Chalk is not food!"; const main = async () => { if (process.argv.length != 4) { console.log(Utils.format("Syntax: {0:s} count message", Utils.filename(process.argv[1]))); process.exit(1); } const REPEATS = Utils.stoiWithDefault(process.argv[2], REPEATS); let message = MESSAGE; if (Utils.cpLength(process.argv[3]) > 0) { message = process.argv[3]; } for (let x = 0; x < REPEATS; ++x) { console.log(message); } } main().catch( e => { console.error(e) } );