diff --git a/tool/src/main/java/com/fidesmo/fdsm/Main.java b/tool/src/main/java/com/fidesmo/fdsm/Main.java index 8cf0f75..8974ea8 100644 --- a/tool/src/main/java/com/fidesmo/fdsm/Main.java +++ b/tool/src/main/java/com/fidesmo/fdsm/Main.java @@ -288,29 +288,21 @@ public static void main(String[] argv) { System.out.println("Not a Fidesmo device"); } } - FidesmoCard fidesmoCard = fidesmoMetadata.orElseThrow(() -> new IllegalStateException("Need a Fidesmo device to continue!")); - if (args.has(OPT_CARD_APPS)) { - List apps = FidesmoCard.listApps(bibo); - if (apps.size() > 0) { - printApps(queryApps(client, apps, verbose), System.out, verbose); - } else { - success("No applications"); - } - } else if (args.has(OPT_RUN)) { + if (args.has(OPT_RUN)) { String service = args.valueOf(OPT_RUN); if (service.startsWith("ws://") || service.startsWith("wss://")) { boolean success = WsClient.execute(new URI(service), bibo, auth).join().isSuccess(); - if (!success) { fail("Fail to run a script"); } else { success(); } - } else { FormHandler formHandler = getCommandLineFormHandler(); + FidesmoCard fidesmoCard = fidesmoMetadata.orElseThrow(() -> new IllegalStateException("Need a Fidesmo device to continue!")); + String appId = null; if (service.contains("/")) { String[] bits = service.split("/"); @@ -338,6 +330,19 @@ public static void main(String[] argv) { success(); // Explicitly quit to signal successful service. Which implies only one service per invocation } } + // --run always exists + } + + // All operations require Fidesmo device + FidesmoCard fidesmoCard = fidesmoMetadata.orElseThrow(() -> new IllegalStateException("Need a Fidesmo device to continue!")); + + if (args.has(OPT_CARD_APPS)) { + List apps = FidesmoCard.listApps(bibo); + if (apps.size() > 0) { + printApps(queryApps(client, apps, verbose), System.out, verbose); + } else { + success("No applications"); + } } else if (requiresAuthentication()) { // XXX if (!auth.getUsername().isPresent()) { throw new IllegalArgumentException("Application ID is required. Use --auth or FIDESMO_AUTH with appId:appKey format");