Ticket #480 (closed enhancement: fixed)

Opened 3 years ago

Last modified 13 months ago

Command line support (request/response/routing)

Reported by: mailing_lists@… Owned by: david
Priority: normal Milestone: 1.0
Component: _OTHER_ Version:
Severity: major Keywords: console commandline
Cc: Patch attached: no

Description

This is my stab at implementing a console request/routing/response. With routing, the command gets called like this:

cli.php <command> -param1 paramvalue1 -param2 -param3 paramvalue3

Without routing, the call is like this:

cli.php <module.action> -param1 paramvalue1 -param2 -param3 paramvalue3

All arguments that start with a dash(-) or double dash (--) will be regarded as paramname and the following argument as param value if it does not start with a dash or double dash. Parameters that have no following argument will be set to "true" to indicate that they have been passed.

Attachments

AgaviConsole.patch.txt Download (11.4 KB) - added by mailing_lists@… 3 years ago.
a patch to enable console apps
Console.patch.txt Download (13.8 KB) - added by ross 2 years ago.
Updated Console patch
autoload.xml Download (0.8 KB) - added by ross 2 years ago.
app/config/autoload.xml
factories.xml Download (1.4 KB) - added by ross 2 years ago.
app/config/factories.xml
ConsoleRequest.class.php Download (2.6 KB) - added by ross 2 years ago.
app/lib/console/ConsoleRequest.class.php
ConsoleResponse.class.php Download (2.7 KB) - added by ross 2 years ago.
app/lib/console/ConsoleResponse.class.php
ProjectBaseAction.class.php Download (0.9 KB) - added by ross 2 years ago.
app/lib/action/ProjectBaseAction.class.php
cli.php Download (1.8 KB) - added by ross 2 years ago.
pub/cli.php
ConsoleRouting.class.php Download (2.5 KB) - added by ross 2 years ago.

Change History

Changed 3 years ago by mailing_lists@…

a patch to enable console apps

Changed 3 years ago by mailing_lists@…

forgot to mention: the patch introduces a new execution type, executeConsole() which falls back to execute() if not declared in the action.

Changed 3 years ago by mailing_lists@…

You must add this to the factories.xml to make the console env work

	<configuration context="console">
		<request class="AgaviConsoleRequest" />
		<routing class="AgaviConsoleRouting" />
		<response class="AgaviConsoleResponse" />
	</configuration>

Changed 3 years ago by david

  • keywords commandline added
  • version HEAD deleted
  • milestone changed from 0.11 to 1.0

Changed 2 years ago by david

  • severity changed from normal to major

Changed 2 years ago by ross

  • has_patch unset

I've adding a new patch - Console.patch.txt. (You might want to split it up into parts before applying to your code base) If needs be I can add the files separately - just ask!

OK - the console files live in app/lib/console and have to be added to autoload.xml There are some changes and by default it calls the console method - I have extended the ProjectBaseAction? to have a handler for executeConsole - so you override that an your away.

The factories.xml has a bit more information in it, like turning off sessions, other than that its much the same as the original - just some extra methods in the core Console classes that were missing.

I've also added an example route in routes.xml which is called from the commandline like so:

   /pub/cli.php /cron/tag_cloud/

Changed 2 years ago by ross

Updated Console patch

Changed 2 years ago by ross

Ok adding all the files separately!

Changed 2 years ago by ross

app/config/autoload.xml

Changed 2 years ago by ross

app/config/factories.xml

Changed 2 years ago by ross

app/lib/console/ConsoleRequest.class.php

Changed 2 years ago by ross

app/lib/console/ConsoleResponse.class.php

Changed 2 years ago by ross

app/lib/action/ProjectBaseAction.class.php

Changed 2 years ago by ross

pub/cli.php

Changed 2 years ago by ross

Changed 2 years ago by ross

Updated ConsoleRouting? so can generate web routes - I needed to generate links in emails sent via a cron job.

Its very basic - but can easily be extended - use AgaviWebRouting? as an example.

I also added a console.xml file to store the basic path information i.e.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configurations>
  <configuration>
    <path>http://www.agavi.org/</path>
   </configuration>
</configurations>

Again this can easily be extended!

Changed 2 years ago by david

  • milestone changed from 1.0 to 1.1

Changed 19 months ago by david

  • milestone changed from 1.1 to 1.0

Changed 18 months ago by jake

I am using this configuration successfully with a few slight modifications. I had to update the config_handlers.xml as follows:

<?xml version="1.0" encoding="UTF-8"?>
<configurations xmlns="http://agavi.org/agavi/1.0/config" parent="%core.system_config_dir%/config_handlers.xml">
        <configuration>
                <handlers>
                        <handler pattern="console.xml" class="AgaviReturnArrayConfigHandler" />
                </handlers>
        </configuration>
</configurations>

I also updated the ConsoleRouting? class to fix some broken usages of the AgaviWebRouting? class that my models were making.

This works great for allowing unit tests to successfully run.

Changed 17 months ago by david

not strictly necessary for 1.0

Changed 14 months ago by david

  • status changed from new to assigned

Changed 14 months ago by david

  • summary changed from Implement Console Request, Routing, Response etc to Command line support (request/response/routing)

Changed 14 months ago by david

  • status changed from assigned to closed
  • resolution set to fixed

(In [3584]) Command line support (request/response/routing), closes #480

Changed 14 months ago by david

(In [3608]) shell exit code support for command line response, refs #480

Add/Change #480 (Command line support (request/response/routing))

Author


E-mail address and user name can be saved in the Preferences.


Action
as closed
Next status will be 'reopened'
 
Note: See TracTickets for help on using tickets.