UNPKG

salesforce-alm

Version:

This package contains tools, and APIs, for an improved salesforce.com developer experience.

36 lines (35 loc) 1.53 kB
import { JsonMap } from '@salesforce/ts-types'; /** * A parser for the CommunityCreateCommand varargs. */ export declare class CommunityNameValueParser { private patterns; /** * The caller/creator of the parser needs to pass in some patterns to validate. * * These patterns are joined together in a RegExp and matched against the "name" portion of the vararg. * * e.g. * let parser = new CommunityNameValueParser([ "name", "template" ]); * parser.parse([ "name=Demo", "template=\"Customer Service\"" ]); // passes * parser.parse([ "name=Demo", "urlpathprefix=pathToDemo" ]); // fails * parser.parse([ "nameOne=Demo" ]); // fails * parser.parse([ "thename=Demo" ]); // fails * parser.parse([ "Name=Demo" ]); // fails * * The patterns are joined between a /^(...)$/ RegExp enclosure so it only accepts exact matches that are case sensitive. (See validate().) * * However, you can use regular expressions to allow for pattern matches. * * let parser = new CommunityNameValueParser([ "name", "template\\.\\w+" ]); * parser.parse([ "template.anything=substance" ]); // passes * parser.parse([ "name=Demo", "template=\"Customer Service\"" ]); // fails * parser.parse([ "name=Demo", "template.=templateOne" ]); // fails */ constructor(patternsToValidate?: string[]); parse(args: string[]): JsonMap; private parseKeyValuePairs; private validate; private buildJsonMapFromKeyValues; private setValue; }