Search in sources :

Example 1 with CmdLineProcessor

use of de.carne.util.cmdline.CmdLineProcessor in project certmgr by hdecarne.

the class CertMgrApplication method evalCmdLine.

@Nullable
private File evalCmdLine() {
    CmdLineProcessor cmdLine = new CmdLineProcessor("certmgr", getParameters().getRaw());
    List<String> defaultArgs = new ArrayList<>();
    cmdLine.onSwitch((s) -> applyLogConfig(Logs.CONFIG_VERBOSE)).arg("--verbose");
    cmdLine.onSwitch((s) -> applyLogConfig(Logs.CONFIG_DEBUG)).arg("--debug");
    cmdLine.onUnnamedOption((s) -> defaultArgs.add(s));
    try {
        cmdLine.process();
        LOG.info("Running command line ''{0}''", cmdLine);
    } catch (CmdLineException e) {
        LOG.warning(e, "Invalid command line ''{0}''; ", cmdLine);
    }
    File defaultStoreHome = null;
    for (String defaultArg : defaultArgs) {
        if (defaultStoreHome == null) {
            defaultStoreHome = new File(defaultArg);
        } else {
            LOG.warning("Ignoring extra store home argument ''{0}''", defaultStoreHome);
        }
    }
    return defaultStoreHome;
}
Also used : Nullable(de.carne.check.Nullable) CmdLineException(de.carne.util.cmdline.CmdLineException) StageController(de.carne.jfx.stage.StageController) Check(de.carne.check.Check) IOException(java.io.IOException) CmdLineProcessor(de.carne.util.cmdline.CmdLineProcessor) Logs(de.carne.boot.logging.Logs) ShutdownHooks(de.carne.util.ShutdownHooks) File(java.io.File) ArrayList(java.util.ArrayList) Images(de.carne.certmgr.jfx.resources.Images) Application(javafx.application.Application) StoreController(de.carne.certmgr.jfx.store.StoreController) List(java.util.List) Stage(javafx.stage.Stage) LogViewImages(de.carne.jfx.stage.logview.LogViewImages) Log(de.carne.boot.logging.Log) LogLevel(de.carne.boot.logging.LogLevel) ArrayList(java.util.ArrayList) CmdLineProcessor(de.carne.util.cmdline.CmdLineProcessor) File(java.io.File) CmdLineException(de.carne.util.cmdline.CmdLineException) Nullable(de.carne.check.Nullable)

Aggregations

Log (de.carne.boot.logging.Log)1 LogLevel (de.carne.boot.logging.LogLevel)1 Logs (de.carne.boot.logging.Logs)1 Images (de.carne.certmgr.jfx.resources.Images)1 StoreController (de.carne.certmgr.jfx.store.StoreController)1 Check (de.carne.check.Check)1 Nullable (de.carne.check.Nullable)1 StageController (de.carne.jfx.stage.StageController)1 LogViewImages (de.carne.jfx.stage.logview.LogViewImages)1 ShutdownHooks (de.carne.util.ShutdownHooks)1 CmdLineException (de.carne.util.cmdline.CmdLineException)1 CmdLineProcessor (de.carne.util.cmdline.CmdLineProcessor)1 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Application (javafx.application.Application)1 Stage (javafx.stage.Stage)1