summaryrefslogtreecommitdiff
path: root/src/org/libreoffice/tools/OptionsHelper.java
blob: d9e2daea5ad7b8d09a87dd2728cd4f888021a53e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package org.libreoffice.tools;

import org.apache.commons.cli.Option;
import org.apache.commons.cli.OptionGroup;
import org.apache.commons.cli.Options;
import org.libreoffice.tools.language.Language;
import org.libreoffice.tools.language.LanguageHelper;
import org.libreoffice.tools.options.Command;
import org.libreoffice.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." );
        generalOptions.addOption( "a", "all", false, "list all interface methods, not only the direct ones" );
        
        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;
    }
}