import chalk from 'chalk'; import type Client from '../../util/client'; import { getCommandName } from '../../util/pkg-name'; import { printAlignedLabel } from '../../util/output/print-aligned-label'; import { AGENT_REASON } from '../../util/agent-output-constants'; import { FLAG_ATTRIBUTE_TYPES, type FlagAttributeType, } from '../../util/flags/attribute-types'; import { defaultEntityLabel, findEntity, parseAttributeInputs, validateAttributeKey, validateEntities, validateEntityKind, validateEntityLabel, type ParsedAttributeInput, } from '../../util/flags/entity-input'; import { getFlagSettings, updateFlagSettings, } from '../../util/flags/get-flags'; import output from '../../output-manager'; import { entitiesCreateSubcommand } from './command'; import type { FlagSettingsEntity } from '../../util/flags/types'; import { getProjectNameFromFlags } from './project'; import { entityAgentError, parseEntityArguments, isExitCodeResult, printEntityDetails, resolveEntitiesProject, } from './entities-common'; export default async function entitiesCreate( client: Client, argv: string[] ): Promise { const parsedArgs = parseEntityArguments( client, argv, entitiesCreateSubcommand.options ); const { args, flags } = parsedArgs; const [kind] = args; let label = (flags['--label'] as string | undefined)?.trim(); const attributeInputs = (flags['--attribute'] as string[] | undefined) ?? []; const json = flags['--json'] as boolean | undefined; const projectName = getProjectNameFromFlags(flags); if (!kind) { if (client.nonInteractive) { entityAgentError(client, { reason: AGENT_REASON.MISSING_ARGUMENTS, message: 'Provide an entity kind to create.', next: [ { command: 'flags entities create --label