OverviewFilesCommitsIssuesDocsReleasesPeers

pgh / lib / commands / profile.js

24 lines · javascript ref:
/** pgh profile show|set [field] [value] */

export const usage = `pgh profile — identity profile

  pgh profile show                         Show your profile (default)
  pgh profile set <name|theme> <value>     Update a profile field`

export async function run (client, args) {
  const sub = args[0] || 'show'

  if (sub === 'show') {
    return client.call('get-profile', {})
  }

  if (sub === 'set') {
    const field = args[1]
    const value = args.slice(2).join(' ')
    if (!field || !value) throw new Error('usage: pgh profile set <name|theme> <value>')
    return client.call('update-profile', { [field]: value })
  }

  throw new Error('unknown profile subcommand: ' + sub + '\n' + usage)
}