civicrm / cv

CiviCRM CLI Utility
28 stars 30 forks source link

Feature request: command line arguments #133

Closed kenahoo closed 1 year ago

kenahoo commented 2 years ago

I asked a Stack Exchange question (https://civicrm.stackexchange.com/questions/42705/cv-script-with-arguments) about how one can pass command-line arguments to a PHP script when running it with cv scr. According to the answer, the only way was to stuff the arguments into environment variables and extract them inside the script.

It would be great to allow passing arguments like this:

% cv scr my_script.php arg1 arg2 arg3

or if that's not possible because the args would be interpreted as belonging to the scr command and not the script being invoked, use the common command-line convention of using -- to separate them:

% cv scr my_script.php -- arg1 arg2 arg3
aydun commented 2 years ago

If you want to have a go at adding this yourself, the code is at https://github.com/civicrm/cv

kenahoo commented 2 years ago

Thanks @aydun - I did have a look already, but I've never used Symfony before so I'd probably need a bit more knowledge. However, in case I or someone else does find time to have a crack at it, some notes are:

aydun commented 1 year ago

@kenahoo If you're still interested in this, see https://github.com/civicrm/cv/pull/143