function parseArgs() {
  const parser = argparse.ArgumentParser({
    description: 'Train an lstm-text-generation model.'
  });
  parser.addArgument('textDatasetNameOrPath', {
    type: 'string',
    help: 'Name of the text dataset (one of ' +
      Object.keys(TEXT_DATA_URLS).join(', ') +
      ') or the path to a text file containing a custom dataset'
  });
  parser.addArgument('modelJSONPath', {
    type: 'string',
    help: 'Path to the trained next-char prediction model saved on disk ' +
    '(e.g., ./my-model/model.json)'
  });
  parser.addArgument('--genLength', {
    type: 'int',
    defaultValue: 200,
    help: 'Length of the text to generate.'
  });
  parser.addArgument('--temperature', {
    type: 'float',
    defaultValue: 0.5,
    help: 'Temperature value to use for text generation. Higher values ' +
    'lead to more random-looking generation results.'
  });
  parser.addArgument('--gpu', {
    action: 'storeTrue',
    help: 'Use CUDA GPU for training.'
  });
  parser.addArgument('--sampleStep', {
    type: 'int',
    defaultValue: 3,
    help: 'Step length: how many characters to skip between one example ' +
    'extracted from the text data to the next.'
  });

  const args = parser.parseArgs();

  const isDataset = TEXT_DATA_URLS[args.textDatasetNameOrPath];
  const isFile = fs.existsSync(args.textDatasetNameOrPath)
    && fs.statSync(args.textDatasetNameOrPath).isFile();
  if (isDataset) {
    args.textDatasetName = args.textDatasetNameOrPath;
    delete args.textDatasetNameOrPath;
  } else if (isFile) {
    args.textDatasetPath = args.textDatasetNameOrPath;
    delete args.textDatasetNameOrPath;
  } else {
    parser.error('Argument should be one of ' +
      Object.keys(TEXT_DATA_URLS).join(', ') +
      ' or the path to a dataset text file');
  }
  return args;
}
Use a trained next-character prediction model to generate some text.