Search in sources :

Example 1 with ArgumentModel

use of org.eclipse.ceylon.common.tool.ArgumentModel in project ceylon by eclipse.

the class DocBuilder method buildRootSynopsis.

private SynopsesSection buildRootSynopsis(ToolModel<?> model) {
    SynopsesSection synopsis = new SynopsesSection();
    synopsis.setTitle(CeylonHelpToolMessages.msg("section.SYNOPSIS"));
    List<Synopsis> synopsisList = new ArrayList<>();
    {
        Synopsis s1 = new Synopsis();
        s1.setInvocation(Tools.progName());
        OptionModel<Boolean> option = new OptionModel<>();
        option.setLongName("version");
        option.setArgumentType(ArgumentType.BOOLEAN);
        ArgumentModel<Boolean> argument = new ArgumentModel<>();
        argument.setMultiplicity(Multiplicity._1);
        argument.setType(Boolean.TYPE);
        option.setArgument(argument);
        // model.getOption("version")));
        s1.setOptionsAndArguments(Collections.singletonList(option));
        synopsisList.add(s1);
    }
    {
        Synopsis s2 = new Synopsis();
        s2.setInvocation(Tools.progName());
        ArrayList<Object> args = new ArrayList<Object>(model.getOptions());
        args.remove(model.getOption("version"));
        /*ArgumentModel<?> options = new ArgumentModel();
            options.setMultiplicity(Multiplicity._0_OR_MORE);
            options.setName("cey\u2011options");
            args.add(options);*/
        ArgumentModel<?> command = new ArgumentModel<>();
        command.setMultiplicity(Multiplicity._1);
        command.setName("command");
        args.add(command);
        ArgumentModel<?> commandOptions = new ArgumentModel<>();
        commandOptions.setMultiplicity(Multiplicity._0_OR_MORE);
        commandOptions.setName("command\u2011options");
        args.add(commandOptions);
        ArgumentModel<?> commandArgs = new ArgumentModel<>();
        commandArgs.setMultiplicity(Multiplicity._0_OR_MORE);
        commandArgs.setName("command\u2011args");
        args.add(commandArgs);
        s2.setOptionsAndArguments(args);
        synopsisList.add(s2);
    }
    synopsis.setSynopses(synopsisList);
    return synopsis;
}
Also used : ArgumentModel(org.eclipse.ceylon.common.tool.ArgumentModel) ArrayList(java.util.ArrayList) OptionModel(org.eclipse.ceylon.common.tool.OptionModel) SynopsesSection(org.eclipse.ceylon.common.tools.help.model.SynopsesSection) Synopsis(org.eclipse.ceylon.common.tools.help.model.Synopsis)

Aggregations

ArrayList (java.util.ArrayList)1 ArgumentModel (org.eclipse.ceylon.common.tool.ArgumentModel)1 OptionModel (org.eclipse.ceylon.common.tool.OptionModel)1 SynopsesSection (org.eclipse.ceylon.common.tools.help.model.SynopsesSection)1 Synopsis (org.eclipse.ceylon.common.tools.help.model.Synopsis)1