<commit_before>#!/usr/bin/env node

// Packages
const minimist = require('minimist')
const chalk = require('chalk')

// Utilities
const logo = require('../../../util/output/logo')
const { handleError } = require('../util/error')

const help = () => {
  console.log(`
  ${chalk.bold(`${logo} now whoami`)}

  ${chalk.dim('Options:')}

    -h, --help              Output usage information
    -c ${chalk.bold.underline('FILE')}, --config=${chalk.bold.underline(
    'FILE'
  )}  Config file
    -d, --debug             Debug mode [off]
    -t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline(
    'TOKEN'
  )} Login token

  ${chalk.dim('Examples:')}

  ${chalk.gray('–')} Show the current team context

    ${chalk.cyan('$ now whoami')}
`)
}

// Options
let argv

const main = async ctx => {
  argv = minimist(ctx.argv.slice(2), {
    boolean: ['help', 'debug', 'all'],
    alias: {
      help: 'h',
      debug: 'd'
    }
  })

  argv._ = argv._.slice(1)

  if (argv.help || argv._[0] === 'help') {
    help()
    process.exit(0)
  }

  await whoami(ctx.config.sh)
}

module.exports = async ctx => {
  try {
    await main(ctx)
  } catch (err) {
    handleError(err)
    process.exit(1)
  }
}

async function whoami({user}) {
  if (process.stdout.isTTY) {
    process.stdout.write('> ')
  }

  const name = user.username || user.email
  console.log(name)
}
<commit_msg>Made `now whoami` return the correct team context (#823)<commit_after>#!/usr/bin/env node

// Packages
const minimist = require('minimist')
const chalk = require('chalk')

// Utilities
const logo = require('../../../util/output/logo')
const { handleError } = require('../util/error')

const help = () => {
  console.log(`
  ${chalk.bold(`${logo} now whoami`)}

  ${chalk.dim('Options:')}

    -h, --help              Output usage information
    -c ${chalk.bold.underline('FILE')}, --config=${chalk.bold.underline(
    'FILE'
  )}  Config file
    -d, --debug             Debug mode [off]
    -t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline(
    'TOKEN'
  )} Login token

  ${chalk.dim('Examples:')}

  ${chalk.gray('–')} Show the current team context

    ${chalk.cyan('$ now whoami')}
`)
}

// Options
let argv

const main = async ctx => {
  argv = minimist(ctx.argv.slice(2), {
    boolean: ['help', 'debug', 'all'],
    alias: {
      help: 'h',
      debug: 'd'
    }
  })

  argv._ = argv._.slice(1)

  if (argv.help || argv._[0] === 'help') {
    help()
    process.exit(0)
  }

  await whoami(ctx.config.sh)
}

module.exports = async ctx => {
  try {
    await main(ctx)
  } catch (err) {
    handleError(err)
    process.exit(1)
  }
}

async function whoami({user, currentTeam}) {
  if (process.stdout.isTTY) {
    process.stdout.write('> ')
  }

  let name = user.username || user.email

  if (currentTeam) {
    name = currentTeam.slug
  }

  console.log(name)
}

{'fraction_non_alphanumeric': 0.19798541160125044, 'fraction_numerical': 0.0045154567558179926, 'mean_word_length': 2.682864450127877, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '4993769', 'n_tokens_mistral': 1060, 'n_tokens_neox': 1030, 'n_words': 221}