Answers.Body: <p>I may be over-thinking this. I can simply add apiv4 functions to any extension and then they are all available via: <code>cv api4 Foo.Bar</code>. I guess you can extend <code>cv</code> after all thanks to the API.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-06T16:06:52.233Z
Answers.LastActivityDate: 2021-08-06T16:06:52.233Z
Answers.UserDisplayName: Jamie
Answers.Body: <p>Something like <code>cv php:script --user=admin my_subcommand.php</code> is kind of the same thing if I understand correctly? You'd just have to put your previous code into a separate php file and adjust.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-05T21:36:47.190Z
Answers.Text: Thanks for the answer. That's workable, but does require typing the path to wherever I put the php file. I suppose I can always stick with drush (or even use drupal console). But, I wonder if there would be interest in developing this feature for `cv`?
Answers.UserDisplayName: Jamie
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-04T20:39:41.047Z
Answers.LastActivityDate: 2021-08-04T20:39:41.047Z
Answers.UserDisplayName: Demerit
Body: <p>I'm starting to work on our Drupal 7 -&gt; Drupal 9 upgrade path. I have a lot of custom drush commands (that mostly run CiviCRM code) to help with provisioning and I'm wondering what to do with them. One option would be to re-write them as <code>cv</code> subcommands - but I don't think that's possible. Is there a way to do that?</p>
  
Tags: <cv>
Title: Can I add custom cv subcommands in my extension?
ThreadText: # Can I add custom cv subcommands in my extension?
  
  (Asked by: username_0 on 2021-08-04)
  
  I'm starting to work on our Drupal 7 -> Drupal 9 upgrade path. I have a lot of custom drush commands (that mostly run CiviCRM code) to help with provisioning and I'm wondering what to do with them. One option would be to re-write them as `cv` subcommands - but I don't think that's possible. Is there a way to do that?
  
  **Tags:** cv
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2021-08-06. Score: 1
  
  I may be over-thinking this. I can simply add apiv4 functions to any extension and then they are all available via: `cv api4 Foo.Bar`. I guess you can extend `cv` after all thanks to the API.
  
  
  ---
  
  ### Answer by username_1 on 2021-08-04. Score: 1
  
  Something like `cv php:script --user=admin my_subcommand.php` is kind of the same thing if I understand correctly? You'd just have to put your previous code into a separate php file and adjust.
  
  > **Comments:**
  > **username_0**: Thanks for the answer. That's workable, but does require typing the path to wherever I put the php file. I suppose I can always stick with drush (or even use drupal console). But, I wonder if there would be interest in developing this feature for `cv`?  
  
  ---
  
  