def parse_command(commands, view):
    import re

    vars = create_variable_values(view)

    asks = []
    templates = []

    if not isinstance(commands, list):
        commands = [commands]

    for command in commands:
        parsed = re.split(r'\${(.*?)}', command)
        # if not variables, return command itself
        if len(parsed) == 1:
            templates.append(command)
            continue

        template_parts = []
        for idx, item in enumerate(parsed, start=1):
            # variable
            auto_variable = 0
            if idx % 2 == 0:
                chs = item.split(':')
                variable_name = chs[0]
                if not variable_name:
                    variable_name = '_' + str(auto_variable)
                    auto_variable += 1
                v = find_defined_value(variable_name, vars)
                if v is not None:
                    template_parts.append(v)
                    continue

                # If the defined variable is not found then either use the default
                # value...
                #
                if len(chs) == 2:
                    template_parts.append(chs[1])
                    continue

                # ...or start prompting:
                #
                if len(chs) < 3:
                    prompt_message = variable_name
                    default_value = ''
                else:
                    prompt_message = chs[2]
                    default_value = chs[1]
                asks.append(dict(variable=variable_name, message=prompt_message, default=default_value))
                template_parts.append('{%s}' % variable_name)
            else:
                template_parts.append(item)
        templates.append(''.join(template_parts))

    return asks, templates
Inspired by Sublime's snippet syntax; "${...}" is a variable.
dataset/ETHPy150Open markbirbeck/sublime-text-shell-command/VariableSubstitution.py/parse_command