@@ -0,0 +1,2885 @@
+/*%0A * This file is part of Bisq.%0A *%0A * Bisq is free software: you can redistribute it and/or modify it%0A * under the terms of the GNU Affero General Public License as published by%0A * the Free Software Foundation, either version 3 of the License, or (at%0A * your option) any later version.%0A *%0A * Bisq is distributed in the hope that it will be useful, but WITHOUT%0A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or%0A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public%0A * License for more details.%0A *%0A * You should have received a copy of the GNU Affero General Public License%0A * along with Bisq. If not, see %3Chttp://www.gnu.org/licenses/%3E.%0A */%0A%0Apackage bisq.cli;%0A%0Aimport java.math.BigDecimal;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.Collections;%0Aimport java.util.HashMap;%0Aimport java.util.List;%0Aimport java.util.Map;%0Aimport java.util.function.Predicate;%0A%0Aimport static java.util.Arrays.stream;%0A%0Aclass NegativeNumberOptions %7B%0A%0A    private final Map%3CInteger, String%3E negativeNumberParams = new HashMap%3C%3E();%0A%0A    String%5B%5D removeNegativeNumberOptions(String%5B%5D args) %7B%0A        // Cache any negative number params that will be rejected by the parser.%0A        // This should be called before command line parsing.%0A        for (int i = 0; i %3C args.length; i++) %7B%0A            if (isNegativeNumber.test(args%5Bi%5D)) %7B%0A                String param = args%5Bi%5D;%0A                negativeNumberParams.put(i - 1, new BigDecimal(param).toString());%0A                args%5Bi%5D = %220%22;  // Substitute a zero so the options parser won't barf.%0A            %7D%0A        %7D%0A        return args;%0A    %7D%0A%0A    List%3CString%3E restoreNegativeNumberOptions(List%3CString%3E nonOptionArgs) %7B%0A        // Put cached negative number params into a clone of the nonOptionArgs list.%0A        // This should be called after command line parsing.%0A        if (!negativeNumberParams.isEmpty()) %7B%0A            List%3CString%3E nonOptionArgsClone = new ArrayList%3C%3E(nonOptionArgs);%0A            negativeNumberParams.forEach((k, v) -%3E %7B%0A                int idx = k;%0A                nonOptionArgsClone.remove(idx);%0A                nonOptionArgsClone.add(idx, v);%0A            %7D);%0A            return Collections.unmodifiableList(nonOptionArgsClone);%0A        %7D else %7B%0A            // This should never happen.  Instances of this class should not be created%0A            // if there are no negative number options.%0A            return nonOptionArgs;%0A        %7D%0A    %7D%0A%0A    static boolean hasNegativeNumberOptions(String%5B%5D args) %7B%0A        return stream(args).anyMatch(isNegativeNumber);%0A    %7D%0A%0A    private static final Predicate%3CString%3E isNegativeNumber = (param) -%3E %7B%0A        if (param.length() %3E 1 && param.startsWith(%22-%22)) %7B%0A            try %7B%0A                new BigDecimal(param);%0A                return true;%0A            %7D catch (NumberFormatException ignored) %7B%0A            %7D%0A        %7D%0A        return false;%0A    %7D;%0A%7D%0A

Add options helper for handling negative number CLI params