package org.openoffice.tools; import org.apache.commons.cli.Option; import org.apache.commons.cli.OptionGroup; import org.apache.commons.cli.Options; import org.openoffice.tools.language.Language; import org.openoffice.tools.language.LanguageHelper; import org.openoffice.tools.options.Command; import org.openoffice.tools.options.SubCommand; /** * Helper class generating the options list. * * @author cbosdonnat * */ public class OptionsHelper { public static final String COMMAND_COMPONENT = "component"; public static final String COMMAND_REGISTRATION = "registration"; // TODO Complete the arguments to handle here protected static Command setupCommandLine( ) { Command cmdLine = new Command(); // General options Options generalOptions = new Options(); OptionGroup langGroup = new OptionGroup(); String[] langs = LanguageHelper.getLanguagesIds( ); for (String lang : langs) { Language langDef = LanguageHelper.getLanguage( lang ); Option langOpt = new Option( lang, false, langDef.getDescription() ); langGroup.addOption( langOpt ); } langGroup.setRequired( true ); generalOptions.addOptionGroup( langGroup ); generalOptions.addOption( "unoinstall", true, "url specifies a URL to an existing UNO environment (URE, office installation)." ); generalOptions.addOption( "o", true, "path specifies an existing directory where the output files are generated to. If path=stdout the generated code is generated on standard out instead of a file." ); cmdLine.setCommonOptions( generalOptions ); // component command options Options compOptions = new Options( ); compOptions.addOption( "t", true, "specifies an UNOIDL type name, e.g. com.sun.star.text.XText" ); compOptions.addOption( "l", true, "specifies a binary type library (can be used more than once). The type library is integrated as an additional type provider in the bootstrapped type system."); compOptions.addOption( "n", true, "specifies an implementation name for the component (used as classname, filename and package|namespace name). In 'dump' mode it is used as classname (e.g. \"MyBase::\", C++ only) to generate method bodies not inline." ); compOptions.addOption( "propertysetmixin", false, "the generated skeleton implements the cppu::PropertySetMixin helper if a referenced new style service specifies an interface which provides attributes (directly or inherited)." ); SubCommand component = new SubCommand( COMMAND_COMPONENT, compOptions, "generates language specific code skeleton files using the implementation name as the file and class name" ); cmdLine.addCommand( component ); // registration options Options regOptions = new Options(); regOptions.addOption( "s", true, "name of the implementation of a service to add to the registration system." ); SubCommand registration = new SubCommand( COMMAND_REGISTRATION, regOptions, "creates the registration code for a list of services implementations. The '-s' option has to be used at least once to specify the implementation name of a service to add to the registration system." ); cmdLine.addCommand( registration ); return cmdLine; } }