import type { Command, LocalCommandCall } from '../types/command.js'
import { VERSION, BUILD_TIME } from '../constants/product.js'

const call: LocalCommandCall = async () => {
  return {
    type: 'text',
    value: BUILD_TIME ? `${VERSION} (built ${BUILD_TIME})` : VERSION,
  }
}

const version = {
  type: 'local',
  name: 'version',
  description:
    'Print the version this session is running (not what autoupdate downloaded)',
  isEnabled: () => process.env.USER_TYPE === 'ant',
  supportsNonInteractive: true,
  load: () => Promise.resolve({ call }),
} satisfies Command

export default version
