Search in sources :

Example 11 with CommandLine

use of aQute.lib.getopt.CommandLine in project bnd by bndtools.

the class Main method _generate.

@Description("Generate additional files for jpm")
public void _generate(GenerateOptions opts) throws Exception {
    if (opts._arguments().isEmpty()) {
        error("Syntax: jpm generate <markdown|bash-completion>");
        return;
    }
    String genType = opts._arguments().get(0);
    if (genType.equalsIgnoreCase("markdown")) {
        IO.copy(this.getClass().getResourceAsStream("/static/jpm_prefix.md"), out);
        CommandLine cl = new CommandLine(this);
        cl.generateDocumentation(this, out);
    } else if (genType.equalsIgnoreCase("bash-completion")) {
        jpm.getPlatform().parseCompletion(this, out);
    // IO.copy(this.getClass().getResourceAsStream("/aQute/jpm/platform/unix/jpm-completion.bash"),
    // out);
    } else {
        error("Syntax: jpm generate <markdown|bash-completion>");
        return;
    }
}
Also used : CommandLine(aQute.lib.getopt.CommandLine) Description(aQute.lib.getopt.Description)

Example 12 with CommandLine

use of aQute.lib.getopt.CommandLine in project bnd by bndtools.

the class AbstractConsoleApp method run.

/**
	 * Main entry
	 * 
	 * @throws Exception
	 */
public void run(String[] args) throws Exception {
    try {
        CommandLine cl = new CommandLine(this);
        ExtList<String> list = new ExtList<String>(args);
        String help = cl.execute(target, "_main", list);
        check();
        if (help != null)
            err.println(help);
    } finally {
        err.flush();
        out.flush();
    }
}
Also used : CommandLine(aQute.lib.getopt.CommandLine) ExtList(aQute.lib.collections.ExtList)

Example 13 with CommandLine

use of aQute.lib.getopt.CommandLine in project bnd by bndtools.

the class bnd method start.

public void start(String[] args) throws Exception {
    CommandLine cl = new CommandLine(this);
    String help = cl.execute(this, "bnd", new ExtList<String>(args));
    check();
    if (help != null)
        err.println(help);
}
Also used : CommandLine(aQute.lib.getopt.CommandLine)

Example 14 with CommandLine

use of aQute.lib.getopt.CommandLine in project bnd by bndtools.

the class bnd method _changes.

public void _changes(ChangesOptions options) {
    boolean first = true;
    Justif j = new Justif(80, 10);
    Formatter f = j.formatter();
    for (Map.Entry<Version, String[]> e : About.CHANGES.entrySet()) {
        if (options.all() || first) {
            f.format("$-\nRelease %s\n$-\n", e.getKey());
            for (String s : e.getValue()) {
                f.format("- \t1%s", s.replace('\n', '\f'));
                Matcher m = BND_COMMAND_P.matcher(s);
                while (m.find()) {
                    Formatter ff = new Formatter();
                    ff.format("\n\n");
                    CommandLine cli = options._command();
                    cli.help(ff, this, m.group(1));
                    j.indent(10, ff.out().toString());
                }
                m = BUG_P.matcher(s);
                while (m.find()) {
                    f.format("\f-> https://github.com/bndtools/bnd/issues/%s", m.group(1));
                }
                f.format("\n\n");
            }
        }
        first = false;
    }
    j.wrap();
    out.println(f.out());
}
Also used : CommandLine(aQute.lib.getopt.CommandLine) Justif(aQute.lib.justif.Justif) Version(aQute.bnd.version.Version) Matcher(java.util.regex.Matcher) Formatter(java.util.Formatter) MultiMap(aQute.lib.collections.MultiMap) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) TreeMap(java.util.TreeMap) HashMap(java.util.HashMap)

Example 15 with CommandLine

use of aQute.lib.getopt.CommandLine in project bnd by bndtools.

the class bnd method _add.

@Description("Add a workspace, or a project or a plugin to the workspace")
public void _add(AddOptions opts) throws Exception {
    List<String> args = opts._arguments();
    String what = args.remove(0);
    if ("project".equals(what)) {
        Workspace ws = Workspace.findWorkspace(getBase());
        if (ws == null) {
            error("No workspace found from %s", getBase());
            return;
        }
        for (String pname : args) {
            ws.createProject(pname);
        }
        getInfo(ws);
        return;
    }
    if ("workspace".equals(what)) {
        for (String pname : args) {
            File wsdir = getFile(pname);
            ws = Workspace.createWorkspace(wsdir);
            if (ws == null) {
                error("Could not create workspace");
            }
        }
        getInfo(ws);
        return;
    }
    if ("plugin".equals(what)) {
        Workspace ws = getWorkspace(getBase());
        if (ws == null) {
            error("No workspace found from %s", getBase());
            return;
        }
        CommandLine cl = new CommandLine(this);
        String help = cl.execute(new Plugins(this, ws), "add", new ExtList<String>(args));
        if (help != null)
            out.println(help);
        getInfo(ws);
        return;
    }
}
Also used : CommandLine(aQute.lib.getopt.CommandLine) File(java.io.File) Workspace(aQute.bnd.build.Workspace) Description(aQute.lib.getopt.Description)

Aggregations

CommandLine (aQute.lib.getopt.CommandLine)19 Description (aQute.lib.getopt.Description)10 File (java.io.File)8 Justif (aQute.lib.justif.Justif)6 DistroOptions (aQute.bnd.main.RemoteCommand.DistroOptions)4 RemoteOptions (aQute.bnd.main.RemoteCommand.RemoteOptions)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 ArrayList (java.util.ArrayList)4 Formatter (java.util.Formatter)3 Workspace (aQute.bnd.build.Workspace)2 Domain (aQute.bnd.osgi.Domain)2 ExtList (aQute.lib.collections.ExtList)2 ReporterAdapter (aQute.libg.reporter.ReporterAdapter)2 Sed (aQute.libg.sed.Sed)2 Reporter (aQute.service.reporter.Reporter)2 RandomAccessFile (java.io.RandomAccessFile)2 Method (java.lang.reflect.Method)2 List (java.util.List)2 Resource (org.osgi.resource.Resource)2 Project (aQute.bnd.build.Project)1