cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robby Pelssers <>
Subject RE: Meet Cocoon CLI
Date Wed, 02 Nov 2011 10:27:47 GMT
Hi Simone,

I was wondering if it would be possible to instead read a (reusable) sitemap from the command
line instead and just provide some match pattern to execute a specific pipeline.  Not sure
if I'm just naïve here but it would make sense to me on first sight.

Usage: c3pipe [options] 

    -f, --file        point to an existing sitemap
    -p  --pattern     the pattern to be handled by the sitemap


-----Original Message-----
From: [] On Behalf Of Simone Tripodi
Sent: Tuesday, November 01, 2011 9:21 PM
Subject: Meet Cocoon CLI

Hi all guys,
I took advantage from today that's been a vacation day here to play
and experiment a little a new cocoon application I proposed time ago,
called cocoon-cli.
I had a private conversation with Cedri Beust, the author of
JCommander, that gave me a little suggestion how to NOT make a CLI
application :P

So, what I did today is replicating the Apache Ant/Maven behavior, I
mean, cocoon-cli is a console application that takes in input an XML
pipeline descriptor - called c3p.xml by default - that looks like very
similar to ant build.xml file:

<pipelines name="Cocoon Pipelines test" default="id0">

  <pipeline id="id0">
    <generator src="${user.dir}/src/test/resources/missing-elements.xml" />
    <serializer />

  <pipeline id="id1">
    <generator src="${user.dir}/src/test/resources/missing-elements.xml" />
    <serializer />


as you can see, it reminds the Ant build XML format, <pipeline>
elements can be associated, as concept, to <target>s, each pipeline
has an id (and an optional description) and the user can specify a
default one has to be executed if no specific one (or more) are
specified in the CLI.
Note that it supports the ${} variables, both Environment and System Properties.

Available commands are:

Usage: c3pipe [options] <pipeline IDs>*.
    -X, --debug  Produce execution debug output.
                      Default: false
    -f, --file        Force the use of an alternate c3p file.
    -h, --help        Display help information.
                      Default: false
    -p, --pipeshelp   Print pipelines help information.
                      Default: false
    -v, --version     Display version information.
                      Default: false

typing `-p`, like Ant, enlists the available pipelines in the actual descriptor:

$ c3pipe -p
[INFO] ------------------------------------------------------------------------
[INFO] Apache Cocoon 3
[INFO] ------------------------------------------------------------------------
[INFO] Apache Cocoon 3 - Pipeline 'Cocoon Pipelines test' (default: id0)
[INFO]     id0 (non-caching) - Description not available
[INFO]     id1 (non-caching) - Description not available
[INFO] ------------------------------------------------------------------------
[INFO] Apache Cocoon 3 SUCCESS
[INFO] Total time: 0s
[INFO] Finished at: Tue Nov 01 20:58:48 CET 2011
[INFO] Final Memory: 10M/493M
[INFO] ------------------------------------------------------------------------

when executing one (or more) pipeline(s), it prints the output in the sysout

[INFO] ------------------------------------------------------------------------
[INFO] Apache Cocoon 3
[INFO] ------------------------------------------------------------------------
[INFO] Executing default Pipeline 'id0'
<?xml version="1.0" encoding="UTF-8"?><!--
  Licensed to the Apache Software Foundation (ASF) under one
  or more contributor license agreements.  See the NOTICE file
  distributed with this work for additional information
  regarding copyright ownership.  The ASF licenses this file
  to you under the Apache License, Version 2.0 (the
  "License"); you may not use this file except in compliance
  with the License.  You may obtain a copy of the License at

  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an
  KIND, either express or implied.  See the License for the
  specific language governing permissions and limitations
  under the License.
 --><!-- $Id: missing-elements.xml 1195964 2011-11-01 12:40:02Z
simonetripodi $ --><pipelines
xmlns:xsi="" name="Valid
Pipeline" default="id0">
    <pipeline id="id0"/>
</pipelines>[INFO] Default pipeline 'id0' executed
[INFO] ------------------------------------------------------------------------
[INFO] Apache Cocoon 3 SUCCESS
[INFO] Total time: 0s
[INFO] Finished at: Tue Nov 01 21:08:35 CET 2011
[INFO] Final Memory: 13M/493M
[INFO] ------------------------------------------------------------------------

To package it, it is enough launching `mvn package` under
/cocoon-cli[1], its execution will produce .tar.gaz and .zip packages
under /cocoon-cli/target, that contain a multi-platform application
which directories tree looks like the Maven one:

├── bin
│   ├── c3pipe
│   └── c3pipe.bat
├── lib
    ├── cocoon-cli-3.0.0-beta-1-SNAPSHOT.jar
    ├── cocoon-pipeline-3.0.0-beta-1-SNAPSHOT.jar
    ├── cocoon-sax-3.0.0-beta-1-SNAPSHOT.jar
    ├── cocoon-util-3.0.0-beta-1-SNAPSHOT.jar
    ├── cocoon-xml-2.0.2.jar
    ├── commons-beanutils-1.8.3.jar
    ├── commons-digester3-3.1.jar
    ├── jcl-over-slf4j-1.6.1.jar
    ├── jcommander-1.17.jar
    ├── logback-classic-0.9.29.jar
    ├── logback-core-0.9.29.jar
    └── slf4j-api-1.6.1.jar

 1) the XSchema is incomplete and doesn't support yet all the
components we have (optionals included);
 2) consequence of 1), the XML parser doesn't ingest all the components;
 3) adding a way to serialize the output to files instead of sysout only;
 4) passing more properties using the -D option in the CLI;
 5) adding a debugger support, ATM the debug option doesn't produce
useful results;
 6) during packaging, properties on filtered resources are not
correctly expanded;
 7) ...

WDYT? Feedbacks are needed and of course participation is open,
everybody interested is welcome! :)
All the best, have a nice day!!!


View raw message