export function parseRawArguments()

in common/utils.ts [58:96]


export function parseRawArguments(rawArgs: string): string[] {
  const initialSplit = rawArgs ? rawArgs.split(',').map(arg => arg.trim()) : []
  const result: string[] = []
  let i = 0

  while (i < initialSplit.length) {
    const currentArg = initialSplit[i]

    // handle --property,prop.name=val1,val2,...
    if (currentArg === '--property') {
      result.push(currentArg)
      const propertyValues: string[] = []

      i++
      while (i < initialSplit.length && !initialSplit[i].startsWith('-')) {
        propertyValues.push(initialSplit[i])
        i++
      }

      result.push(propertyValues.join(','))
      // handle --property prop.name=val1,val2,...
    } else if (currentArg.startsWith('--property ')) {
      const fullPropertyArg: string[] = [currentArg]

      i++
      while (i < initialSplit.length && !initialSplit[i].startsWith('-')) {
        fullPropertyArg.push(initialSplit[i])
        i++
      }

      result.push(fullPropertyArg.join(','))
    } else {
      result.push(currentArg)
      i++
    }
  }

  return result
}