composer-substitution-plugin icon indicating copy to clipboard operation
composer-substitution-plugin copied to clipboard

Replace placeholders from cli arguments

Open mdjdev opened this issue 1 year ago • 2 comments

Hi,

I'm interested in replacing placeholders with arguments that are passed with the Composer command.

Here is a simple example:

"scripts": {
    "welcome": "echo 'Hi {MY_NAME}, the database is {DB_STATUS}.'"
}
"extra": {
    "substitution": {
        "enable": true,
        "mapping": {
            "{MY_NAME}": {
                "type": "cli-argument",
                "value": "$1"
            },
            "{DB_STATUS}": {
                "type": "cli-argument",
                "value": "$2",
            }
        }
    }
}
$ composer run-script welcome "John Doe" "OK"
Hi John Doe, the database is OK.

Is this a feature that could be added?

mdjdev avatar Jan 30 '24 10:01 mdjdev

Hi @mdjdev,

I like the idea :)

Please open a PR if you feel comfortable, otherwise I'll try to find some time to implement it.

villfa avatar Jan 30 '24 11:01 villfa

@villfa Thank you for your favorable response. I would appreciate it if you could take a look if you have the time.

mdjdev avatar Feb 05 '24 09:02 mdjdev