Add Else parameter
Opened this issue · 0 comments
When a format parameter contains a reference to an named capture, but this capture is not resolved, currently, there is a rule which prevents the remaining placeholder to be removed. Before applying this rule, we should be able to replace these unresolved captures as per user request. The user should be able to provide an else parameter, which is a compound string of the form:
"<named-capture-a>,<else-value-a>;<named-capture-b>,<else-value-b>;...<named-capture-n>,<else-value-n>"
where named-capture-n is the name of the capture group and else-value-n is the else value that should be used for that capture if it is unresolved.
Eg:
for regular expression (git commit message check-in format, not a good example for renaming files/directories, but the point is still being made):
"^(?(?fix|feat|build|chore|ci|docs|doc|style|ref|perf|test)\s+(?:#(?\d{1,6}))?)?(?!)?:\s(?[\w\W\s]+)"
the named groups are:
- type
- issue
- break
- body
so the user should be able to provide else specifiers for any of these groups
Rename-Many ... -Paste "COMMIT: ${type}, ISSUE: ${issue}" -Else 'type,none;issue,-'
"<named-capture-a>:<else-value-a>|<named-capture-b>:<else-value-b>|...|<named-capture-n>:<else-value-n>"