import { CliLeaf, CliStringInput } from '@alwaysai/alwayscli';
import { yesCliInput } from '../../cli-inputs';
import { appPackageComponent } from '../../components/app';
import { ALWAYSAI_SHOW_HIDDEN } from '../../environment';

export const appPackageCliLeaf = CliLeaf({
  name: 'package',
  description: 'Package this application as a Docker image',
  namedInputs: {
    yes: yesCliInput,
    tag: CliStringInput({
      description:
        'Tag for application Docker image. Format: <dockerhub-user>/<img-name>:<version>'
    })
  },
  hidden: !ALWAYSAI_SHOW_HIDDEN,
  async action(_, opts) {
    const { yes, tag } = opts;
    await appPackageComponent({
      yes,
      dockerImageTag: tag
    });
  }
});
