public UpdateArguments parseArguments()

in src/main/java/com/awslabs/aws/greengrass/provisioner/implementations/helpers/BasicUpdateArgumentHelper.java [30:74]


    public UpdateArguments parseArguments(String[] args) {
        UpdateArguments updateArguments = new UpdateArguments();

        JCommander.newBuilder()
                .addObject(updateArguments)
                .build()
                .parse(args);

        if (!updateArguments.isRequiredOptionSet()) {
            throw new RuntimeException("This is not an update request");
        }

        if (updateArguments.groupName == null) {
            throw new RuntimeException("Group name is required for all operations");
        }

        Try triedSubscriptionTableEntriesPresent = Try.of(() -> subscriptionTableEntriesPresent(updateArguments));

        if ((updateArguments.addSubscription || updateArguments.removeSubscription) &&
                triedSubscriptionTableEntriesPresent.isFailure()) {
            // They want to add/remove a subscription but haven't specified the necessary subscription table entries
            throw new RuntimeException(triedSubscriptionTableEntriesPresent.getCause());
        }

        if ((updateArguments.addFunction != null) || (updateArguments.removeFunction != null)) {
            // They want to add/remove a function...
            if (updateArguments.functionAlias == null) {
                // ...but haven't specified the alias
                throw new RuntimeException("No function alias specified");
            }
        }

        if (updateArguments.addFunction != null) {
            // They want to add a function...
            if (updateArguments.functionBinary == false) {
                log.warn("Binary encoding not specified, defaulting to JSON");
            }

            if (updateArguments.functionPinned == false) {
                log.warn("Function not specified as pinned, defaulting to event driven only");
            }
        }

        return updateArguments;
    }