Feature #4426

Provide Windows compatible version of the FLOW3 Command Line Tool

Added by Bastian Waidelich almost 6 years ago. Updated almost 5 years ago.

Status:Resolved Start date:
Priority:Should have Due date:
Assigned To:Bastian Waidelich % Done:

100%

Category:Core
Target version:TYPO3 Flow Base Distribution - 1.0 beta 1
PHP Version: Complexity:
Has patch:

Description

FLOW3 distribution comes with an easy to use command line tool (see http://flow3.typo3.org/documentation/tutorials/getting-started/gettingstarted.kickstart/#gettingstarted.kickstart.commandlinetool).
For the good old Windows users we should supply a similar batch version of the script.

flow3.bat (5 kB) Bastian Waidelich, 2009-09-03 13:54

4426_v1.patch Magnifier (80.8 kB) Bastian Waidelich, 2009-09-29 16:43

4426_v2.patch Magnifier (76.3 kB) Karsten Dambekalns, 2009-09-30 12:47

4426_v3.patch Magnifier - Fixed v2 patch file (76.2 kB) Karsten Dambekalns, 2009-10-27 16:48

4426_v4.patch Magnifier (73.7 kB) Bastian Waidelich, 2010-04-15 00:58

flow3.bat - wrapper for the flow3 script (254 Bytes) Bastian Waidelich, 2011-06-21 16:31

flow3_dev.bat - wrapper for the flow3_dev script (258 Bytes) Bastian Waidelich, 2011-06-21 16:31


Related issues

related to TYPO3 Flow Base Distribution - Bug #27482: CLI not working on Windows Resolved 2011-06-15
related to TYPO3.Flow - Feature #4469: Implement a central command line controller Resolved 2009-09-07
related to TYPO3.Flow - Feature #6681: Make the php cli executable configurable for the flow3 co... Resolved 2010-03-03
related to TYPO3.Flow - Feature #7216: Custom CLI Controller without Modification of flow3.sh Closed 2010-04-12

Associated revisions

Revision e7681c8c
Added by Karsten Dambekalns about 4 years ago

[TASK] Simplify CLI use, add batch file

Removes the two scripts for Development and Production context and
keeps one script instead. To change the context, use the environment
variable FLOW3_CONTEXT.

Also adds a flow3.bat file for use on Windows.

Change-Id: Idd7d74c6c4a2ad4b88f3d5849681d2bb289e94b9
Fixes: #27482
Resolves: #4426

History

#1 Updated by Bastian Waidelich almost 6 years ago

Attached is a very first (incomplete) version of a batch script "ported" from the FLOW3 Command Line Tool to Windows batch.
The good news: If placed next to the original "flow3" script, it will work directly as described in the tutorial ("flow3 package create foo") as *.bat files take precedence over files without extension.
The bad news: Windows batch sucks and there is a lot of duplication.. If someone is familiar with this "language", please help!

#2 Updated by Bastian Waidelich almost 6 years ago

Thought:
In order to avoid too much duplication the script might be turned into a PHP script that is only invoked by the CLI..

#3 Updated by Irene Höppner almost 6 years ago

I know somebody who can do that script, but he said the current version is too hard.... if we move the main stuff to php, he would do the windows-script.

#4 Updated by Karsten Dambekalns almost 6 years ago

We should definitely move the logic to PHP and use shell / batch only to invoke that. The same style works well for PEAR, phpunit, phpcs, ... Any chance to get this done until end of this month to have it in alpha 5?

#5 Updated by Bastian Waidelich almost 6 years ago

Karsten Dambekalns wrote:

We should definitely move the logic to PHP and use shell / batch only to invoke that. [...]
Any chance to get this done until end of this month to have it in alpha 5?

I was playing around with a script, that is able to determine possible parameters and method descriptions for configured actions..
You would configure the possible commands like

cli:
  commandSets:
    package:
      controller: F3\FLOW3\Package\Controller\ManagerController
      actions: [listAvailable, listActive, create, activate, deactivate, delete]
    cache:
      controller: F3\FLOW3\Cache\Controller\ManagerController
      actions: [flush]
    testing:
      controller: F3\Testing\Controller\CLIController
      actions: [run]
    kickstart:
      controller: F3\Kickstart\Controller\KickstartController
      actions: [generatePackage, generateController, generateModel, generateRepository]

In my first tests this worked quite well.. Though, as discussed @ t3con09, this requires configuration manager & mvc framework to work. If there was a syntax error in one of the classes, there is no possibility to execute commands.
I'd suggest to implement something like that anyways, and later think about some fallback mechanism.

I'll clean up my prototype and upload it here, but I can't promise to be done until next week..

#6 Updated by Karsten Dambekalns almost 6 years ago

  • Status changed from New to Accepted

#7 Updated by Bastian Waidelich almost 6 years ago

Attached is a very first version of a new FLOW3 subpackage "CLI".
It contains of three main classes:
  • "Host" abstracts console commands like output(), outputLine() and readLine() and allows you to register commands
  • "Command" can contain CommandArguments and may be registered at the Host
  • "CommandArgument" very simple class, that exists of the properties name, description and a required-flag

Additionally the patch replaces the current "flow3" shell script by a simplified version that forwards control to the new CLI script FLOW3/Scripts/FLOW3CLI.php. Last but not least the patch comes with a "translated" batch version for windows.

Note: This is experimental and not yet complete. Besides, there are still some issues to be solved (like actually firing the actions, a fallback)

#8 Updated by Karsten Dambekalns almost 6 years ago

v2: The patch has been updated in some areas:
  • shell script works now
  • reflection service changes
  • reading from STDIN has been simplified
  • some comment and style cleanup

All in all it works and seems the way to go!

#9 Updated by Bastian Waidelich almost 6 years ago

Karsten Dambekalns wrote:

Hi Karsten,

v2: The patch has been updated in some areas:

I can't apply your patch for some reason - can you please recreate it only for FLOW3 package?

Thanks
Bastian

#10 Updated by Karsten Dambekalns almost 6 years ago

Bastian Waidelich wrote:

I can't apply your patch for some reason - can you please recreate it only for FLOW3 package?

Probably the problem caused by the superfluous line at line 1004 that manifests itself as an error on line 991 when patching. Try again with v3.

As soon as my subversion build is through I can hopefully create patches with line numbers again, then I can create a seperate patch for FLOW3...

#11 Updated by Karsten Dambekalns over 5 years ago

  • Target version set to 1.0 alpha 8

#12 Updated by Karsten Dambekalns over 5 years ago

  • Target version changed from 1.0 alpha 8 to 1.0 alpha 9

#13 Updated by Robert Lemke over 5 years ago

  • Start date deleted (2009-09-03)

#14 Updated by Bastian Waidelich over 5 years ago

  • File 4426_v4.patchMagnifier added
  • Category set to Core
  • Status changed from Accepted to Needs Feedback

Attached version works for me. With following snippet pasted to "Settings.yaml":

FLOW3:
  cli:
    commandSets:
      foo:
        controller: F3\FLOW3\Package\Controller\PackageManagerController
        actions: [create, delete]
      bar:
        controller: F3\Kickstart\Controller\KickstartController
        actions: [generatePackage]

But I'm not happy with it, because it is pretty slow to load up (at least on Windows) and it relies on a lot of parts of the framework..
An option might be to store the avaivable commands in a text file and add a command that recreates that textfile on request.

Please test and give feedback

#15 Updated by Robert Lemke about 5 years ago

  • Target version deleted (1.0 alpha 9)

#16 Updated by Bastian Waidelich about 4 years ago

With the current implementation, this issue is (almost) resolved.
We still need a small batch wrapper as described above.
Apart from that, unfortunately interactive shell won't be possible on Windows.. readline_read_history() and readline_completion_function() are not available on PHP for Windows.. The current shellCommand should check the existence of this functions to avoid fatal errors.

#17 Updated by Bastian Waidelich about 4 years ago

Attached are two very simple batch wrappers for the flow3/flow3_dev scripts allowing it to use the CLI commands from the normal Windows bash.
Place the scripts in Packages/Framework/FLOW3/Scripts and create a symlink at the root of your installation (or put them directly in the root).
NOTE: Make sure to verify that flow3 & flow3_dev are symlinked correctly (see #27482)

#18 Updated by Mr. Hudson about 4 years ago

  • Status changed from Needs Feedback to Under Review

Patch set 1 of change Ie4b3d9d5f620572b926b7f975102b2b09471c42b has been pushed to the review server.
It is available at http://review.typo3.org/3049

#19 Updated by Mr. Hudson about 4 years ago

Patch set 1 of change Ibfae85839e4620e584af141e62c3c5886f575a4e has been pushed to the review server.
It is available at http://review.typo3.org/3053

#20 Updated by Mr. Hudson about 4 years ago

Patch set 1 of change Idd7d74c6c4a2ad4b88f3d5849681d2bb289e94b9 has been pushed to the review server.
It is available at http://review.typo3.org/3056

#21 Updated by Mr. Hudson about 4 years ago

Patch set 2 of change Idd7d74c6c4a2ad4b88f3d5849681d2bb289e94b9 has been pushed to the review server.
It is available at http://review.typo3.org/3056

#22 Updated by Mr. Hudson about 4 years ago

Patch set 3 of change Idd7d74c6c4a2ad4b88f3d5849681d2bb289e94b9 has been pushed to the review server.
It is available at http://review.typo3.org/3056

#23 Updated by Sebastian Kurfuerst almost 5 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 80 to 100

Also available in: Atom PDF