You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Standard naming conventions and search locations for command files #12
Currently, the CommandFileDiscovery class searches for command files named *Commands.php in directories named CliTools (or src/CliTools).
In Drush, I tried an alternative search pattern, and currently look for command files named "*CommandFile.php" in directories named CommandFiles (or src/CommandFiles).
Ideally, we should decide on a single standard default that both Drush and DrupalConsole can use, so that command files are found consistently. At the moment, I am leaning towards the second option, and calling these literally CommandFiles, as Drush is currently doing. Other conventions are possible, of course; anyone with opinions on the subject should weigh in.
Another thing that would be sensible would be to search for *Commands.php in Command -- same directory as Symfony Console's standard, but a (slightly) different filename. Symfony Console command files implement one command -- annotation command files can provide multiple commands.
I personally like the structure that Symfony Console provide *Command.php in src/Command. I think is going to be confusing for anyone that have to contribute before to a Symfony Console project and is now trying to contribute to either Drush or Drupal Console.
Since this mainly for support for annotation commands what about *Annotation.php in src/Command/Annotation/ or src/Annotation. This will allow users to either write commands in the Symfony Console way or Annotation way.
Yes, I agree that it should be possible to write either a Symfony Console command or a new annotation command. The proposed PR in DrupalConsole, hechoendrupal/drupal-console#2081, supports this.
Annotations can be used for many things other than defining commands, though, so I think that *Annotation.php is a bit too generic, and src/Annotation is a little too hidden. I like sharing src/Command, since that makes the new commands discoverable. src/Command/Annotation is at least in the right location, but I tend to think that someone who was familiar with Symfony would expect to see annotations that affect Symfony commands in that location -- not more commands. *Commands.php has the advantage of being short and visible.
src/Command/*AnnotationCommand.php would also meet all of the criteria, but is a bit long.
I think the command classes miss a neat name, "command class instance" is a bit long and clumsy. What about just going with CommandHandler? Then we could use a CommandHandler namespace and have a clear differentation to CommandHandlers that provide multiple commands and Command classes ?
Activity
weitzman commentedon Apr 10, 2016
No strong opinion here. I think the
Filesuffix is a bit redundant (andToolsas well).greg-1-anderson commentedon Apr 10, 2016
Symfony Console searches for
*Command.phpinCommand, so we shouldn't use that.Other options:
*Commands.phpinCommands*Cli.phpinCligreg-1-anderson commentedon Apr 10, 2016
Another thing that would be sensible would be to search for
*Commands.phpinCommand-- same directory as Symfony Console's standard, but a (slightly) different filename. Symfony Console command files implement one command -- annotation command files can provide multiple commands.itsdarrylnorris commentedon Apr 10, 2016
My two cents....
I personally like the structure that Symfony Console provide
*Command.phpinsrc/Command. I think is going to be confusing for anyone that have to contribute before to a Symfony Console project and is now trying to contribute to either Drush or Drupal Console.Since this mainly for support for annotation commands what about
*Annotation.phpinsrc/Command/Annotation/orsrc/Annotation. This will allow users to either write commands in the Symfony Console way or Annotation way.greg-1-anderson commentedon Apr 10, 2016
Yes, I agree that it should be possible to write either a Symfony Console command or a new annotation command. The proposed PR in DrupalConsole, hechoendrupal/drupal-console#2081, supports this.
Annotations can be used for many things other than defining commands, though, so I think that
*Annotation.phpis a bit too generic, andsrc/Annotationis a little too hidden. I like sharingsrc/Command, since that makes the new commands discoverable.src/Command/Annotationis at least in the right location, but I tend to think that someone who was familiar with Symfony would expect to see annotations that affect Symfony commands in that location -- not more commands.*Commands.phphas the advantage of being short and visible.src/Command/*AnnotationCommand.phpwould also meet all of the criteria, but is a bit long.greg-1-anderson commentedon Apr 11, 2016
src/Command/*AnnotatedCommand.phpis another viable alternative.greg-1-anderson commentedon Apr 11, 2016
I prefer the shorter variation myself, but am not super strongly attached with it, and could go with ^^ if that's what most folks want to see.
fago commentedon Apr 16, 2016
I think the command classes miss a neat name, "command class instance" is a bit long and clumsy. What about just going with CommandHandler? Then we could use a CommandHandler namespace and have a clear differentation to CommandHandlers that provide multiple commands and Command classes ?
greg-1-anderson commentedon Aug 2, 2016
Ended up leaving the defaults as they were. Each individual project may set the search locations they prefer, though.