<commit_before>async = require 'async'
{program, client, delay, handleError, runJsFile, runJs, exit} = require './common'
PreviousStatementsDownloader = require './previous-statements-downloader'

process.on 'uncaughtException', (err) ->
  console.error "Uncaught exception occurred!"
  console.error "ERROR: #{err.message}"
  console.error err.stack
  console.error require('util').inspect err, {colors: true}
  console.error "Exiting."

# Make string safe for filenames
slug = (string) ->
  return string.replace(/\s+/g, "-").replace(/[^A-Z0-9-]+/gi, "")

# For if you're using the REPL
myRepl = null
echoDone = (err, result) ->
  myRepl.context.lastError = err
  myRepl.context.lastResult = result
  if err
    outputError(err)
  else
    console.log "Done, result is in `lastResult` variable."

repl = (callback = mainMenu) ->
  options =
    prompt: "HSBCScrape REPL> "
    useGlobal: true
    ignoreUndefined: true
  # Vanilla JS REPL:
  myRepl = require('repl').start options
  # Export useful things
  myRepl.context[key] = value for key, value of {client, delay, program, echoDone, runJs, runJsFile}
  myRepl.on 'exit', ->
    callback()

mainMenu = ->
  accountList = null
  chosenAccount = null
  async.series
    loadMyAccountsPage: (next) ->
      console.log "Loading my accounts..."
      client.url  "https://www.hsbc.co.uk/1/3/personal/internet-banking", next
    getListOfAccounts: (next) ->
      console.log "Parsing list of accounts"
      runJsFile "accountlist", (err, list) ->
        if err
          console.error err
          return next err
        console.log list
        accountList = list
        next()
    chooseAccount: (next) ->
      console.log "Which account would you like to look at?"
      options = ("#{account.name} (#{account.details})" for account in accountList)
      program.choose options, (i) ->
        process.stdin.pause()
        chosenAccount = accountList[i]<commit_msg>Remove unnecessary log line.<commit_after>async = require 'async'
{program, client, delay, handleError, runJsFile, runJs, exit} = require './common'
PreviousStatementsDownloader = require './previous-statements-downloader'

process.on 'uncaughtException', (err) ->
  console.error "Uncaught exception occurred!"
  console.error "ERROR: #{err.message}"
  console.error err.stack
  console.error require('util').inspect err, {colors: true}
  console.error "Exiting."

# Make string safe for filenames
slug = (string) ->
  return string.replace(/\s+/g, "-").replace(/[^A-Z0-9-]+/gi, "")

# For if you're using the REPL
myRepl = null
echoDone = (err, result) ->
  myRepl.context.lastError = err
  myRepl.context.lastResult = result
  if err
    outputError(err)
  else
    console.log "Done, result is in `lastResult` variable."

repl = (callback = mainMenu) ->
  options =
    prompt: "HSBCScrape REPL> "
    useGlobal: true
    ignoreUndefined: true
  # Vanilla JS REPL:
  myRepl = require('repl').start options
  # Export useful things
  myRepl.context[key] = value for key, value of {client, delay, program, echoDone, runJs, runJsFile}
  myRepl.on 'exit', ->
    callback()

mainMenu = ->
  accountList = null
  chosenAccount = null
  async.series
    loadMyAccountsPage: (next) ->
      console.log "Loading my accounts..."
      client.url  "https://www.hsbc.co.uk/1/3/personal/internet-banking", next
    getListOfAccounts: (next) ->
      console.log "Parsing list of accounts"
      runJsFile "accountlist", (err, list) ->
        if err
          console.error err
          return next err
        accountList = list
        next()
    chooseAccount: (next) ->
      console.log "Which account would you like to look at?"
      options = ("#{account.name} (#{account.details})" for account in accountList)
      program.choose options, (i) ->
        process.stdin.pause()
        chosenAccount = accountList[i]
{'fraction_non_alphanumeric': 0.13000520020800832, 'fraction_numerical': 0.0020800832033281333, 'mean_word_length': 3.1724511930585684, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '856920', 'n_tokens_mistral': 1211, 'n_tokens_neox': 1202, 'n_words': 334}