import { BudgieUtilities } from "../../BudgieUtilities" ; import { LineResults } from "../LineResults" ; import { CommandNames } from "../Names/CommandNames" ; import { KeywordNames } from "../Names/KeywordNames" ; import { Command } from "./Command" ; import { CommandResult } from "./CommandResult" ; import { CommandMetadata } from "./Metadata/CommandMetadata" ; import { KeywordParameter } from "./Metadata/Parameters/KeywordParameter" ; import { SingleParameter } from "./Metadata/Parameters/SingleParameter" ; import { addLineEnder } from "./Utilities" ; /**
 * Starts an enum declaration.
 */ export class EnumStartCommand extends Command { /**
     * Metadata on the command.
     */ private static metadata : CommandMetadata = new CommandMetadata ( CommandNames . EnumStart ) . withDescription ( "Starts an enum declaration" ) . withIndentation ( [ 1 ] ) . withParameters ( [ new KeywordParameter ( [ KeywordNames . Export ] , "Keyword to export this enum publicly." , false ) , new SingleParameter ( "name" , "Name of the enum." , true ) , ] ) ; returns public getMetadata ( ) { return EnumStartCommand . metadata ; } param parameters returns public render ( parameters ) { const remainingParameters = parameters . slice ( 1 ) ; const isExported = this . getForExport ( remainingParameters ) ; const lines = [ new CommandResult ( "" , 0 ) ] ; let lineStart = "" ; if ( isExported ) { lineStart += BudgieUtilities . stringReplaceAll ( this . language . syntax . enums . declareExternal , "{0}" , remainingParameters [ 0 ] ) ; } else { lineStart += BudgieUtilities . stringReplaceAll ( this . language . syntax . enums . declareInternal , "{0}" , remainingParameters [ 0 ] ) ; } addLineEnder ( lines , lineStart , 1 ) ; return new LineResults ( lines ) . withImports ( this . language . syntax . enums . requiredImports ) ; } param remainingParameters returns private getForExport ( remainingParameters ) { if ( remainingParameters [ 0 ] !== KeywordNames . Export ) { return false ; } remainingParameters . shift ( ) ; return true ; } }