import arg from 'arg'
import { logInfo } from '../log'
import { DeploymentPlatformClient } from 'deployment-platform-client'

export const deployHandler = cliArgs => {
  logInfo({  message: 'Running deploy command' })

  const parsedArgs = arg({
    '--username': String,
    '-u': '--username',

    '--authentication': String,
    '--a': '--authentication',

    '--target-env': String,
    '-t': '--target-env',

    '--ossyfile': String,
    '-o': '--ossyfile',

    '--platforms': String,
    '-p': '--platforms'
  }, { argv: cliArgs })

  DeploymentPlatformClient.deploy(
    parsedArgs['--username'],
    parsedArgs['--authentication'],
    parsedArgs['--target-env'],
    parsedArgs['--platforms'],
    parsedArgs['--ossyfile']
  )
}
