Bug 45971

Summary: [PATCH] Fop CLI Errors
Product: Fop - Now in Jira Reporter: Tom Browder <tom.browder>
Component: generalAssignee: fop-dev
Status: CLOSED FIXED    
Severity: normal CC: tom.browder
Priority: P2    
Version: all   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Attachments: Patch to correct the bugs.

Description Tom Browder 2008-10-08 18:05:16 UTC
Created attachment 22699 [details]
Patch to correct the bugs.

The following problems are associated with the command line interface (CLI) to Fop:

1.  Running 'fop' with no arguments throws an exception after printing
a usage statement.

2.  Running 'fop -v' throws an exception after printing the version.

3.  Current usage and help messages refer to 'Fop' while the user
executes 'fop'.

The attached patch was generated by running 'svn diff' at the top of
the working directory of a checked-out fop trunk at revision 702651.

It affects the following files:

 src/java/org/apache/fop/cli/CommandLineOptions.java
 src/java/org/apache/fop/cli/Main.java

It corrects all three issues listed above.
Comment 1 Vincent Hennebert 2008-10-13 03:48:58 UTC
Hi Tom,

Good thing you created a bug report for this, it was being forgotten. Patch applied in revision 704008 (http://svn.apache.org/viewvc?view=rev&revision=704008). The following modifications were made:
- minor style fixes (illegal tab characters)
- System.exit is called at only two places: with a return value of 1 when an unknown argument is given; with a return value of 0 in all other cases. The rationale is that it's not erroneous to simply run fop without argument, or with -v or -h.
- the help message is accordingly sent to either stderr or stdout

The semantic of the boolean return value has been changed: false now indicates that processing should stop normally, not because of an error (there are exceptions for that).

Ideally this whole part of the code should be re-worked to make use of a common command-line parsing library (Apache Commons CLI), but this patch is a reasonable trade-off.

Please re-open the bug if you're not happy with the modifications made.
Thanks Tom!
Vincent
Comment 2 Tom Browder 2008-10-13 18:02:20 UTC
Patch looks good, Vincent.  Thanks!

-Tom
Comment 3 Tom Browder 2010-11-01 19:27:41 UTC
(In reply to comment #2)
> Patch looks good, Vincent.  Thanks!
> 
> -Tom

Vincent, I was disappointed not to see this fix mentioned in the change list for the 1.0 release.  I know it's not major, but it did change the CLI response to fop.
Comment 4 Vincent Hennebert 2010-11-08 07:12:33 UTC
(In reply to comment #3)
> (In reply to comment #2)
> > Patch looks good, Vincent.  Thanks!
> > 
> > -Tom
> 
> Vincent, I was disappointed not to see this fix mentioned in the change list
> for the 1.0 release.  I know it's not major, but it did change the CLI response
> to fop.

Hi Tom,

When we commit changes we usually add an entry to the status.xml file at the root of the project. The changes are then reflected on the website:
http://xmlgraphics.apache.org/fop/1.0/changes_1.0.html

I don't remember back then if I just forgot to add an entry relating to this issue, or if I judged that that was too small a change to warrant a log. I've now added one:
http://svn.apache.org/viewvc?view=revision&revision=1032549

It will appear on the website soon. A bit late I admit but that may help other users. Was that what you were looking for?

Regards,
Vincent
Comment 5 Glenn Adams 2012-04-01 06:45:29 UTC
batch transition pre-FOP1.0 resolved+fixed bugs to closed+fixed