/* * Copyright (C) 2024 JPEXS * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ package com.jpexs.decompiler.flash.console; import com.jpexs.helpers.utf8.Utf8Helper; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintStream; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; import org.fusesource.jansi.AnsiConsole; /** * * @author JPEXS */ public class CommandLineHelp { private static Map> commands = new LinkedHashMap<>(); private static Map preOptions = new LinkedHashMap<>(); private static String preface = null; private static Map aliasMap = new HashMap<>(); static { parse(); } private static String getPreface(String command, String arguments) { String ret = preface; if (command != null) { ret = ret.replace("[COMMAND]", command + "\\\r\n " + arguments); } ret = ret.replace("Usage:", "@|bold,underline Usage|@:"); ret = ret.replace("Executable:", "@|bold,underline Executable|@:"); return ret; } private static String hilight(String str) { str = str.replaceAll("<[a-zA-Z_0-9]+>", "@|italic $0|@"); str = str.replaceAll("(^|[ \\[\\(\\|\n])(-[a-zA-Z_0-9]+)", "$1@|yellow $2|@"); str = str.replaceAll("@\\|yellow (-[a-zA-Z_0-9]+)\\|@ command", "@|bold $1|@ command"); return str; } private static String indentArguments(String arguments, String commandName) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < commandName.length(); i++) { sb.append(" "); } sb.append(" "); return arguments.replace("\r\n", "\r\n" + sb.toString()); } private static class Command { String name; String customSynopsis; String arguments; String header; String description; List aliases; List