/* ### * IP: GHIDRA * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ //Creates a template help file by reading all of the actions from a selected plugin. //@category HELP import java.io.*; import java.util.*; import docking.action.DockingActionIf; import ghidra.app.script.GhidraScript; import ghidra.framework.plugintool.Plugin; import ghidra.framework.plugintool.PluginTool; import ghidra.util.exception.CancelledException; public class CreateHelpTemplateScript extends GhidraScript { @Override protected void run() throws Exception { PluginTool tool = state.getTool(); Plugin[] plugins = getSortedPlugins(tool); Plugin selectedPlugin = askChoice("Select Plugin To Use To Generate Help", "Plugin", plugins, plugins[0]); if (selectedPlugin == null) { printerr("no plugin selected, no help template created."); return; } File outputDirectory = askDirectory("Select Directory To Write Help File", "GO!"); if (outputDirectory == null) { printerr("no output directory selected, no help template created."); return; } File outputFile = new File(outputDirectory, selectedPlugin.getName() + ".html"); if (outputFile.exists()) { boolean keepExisting = askYesNo("Help File Already Exists", "The help file for " + selectedPlugin.getName() + " already exists.\nDo you want to keep the existing file?"); if (keepExisting) { printerr("output help file already exists, user chose to keep existing."); return; } } writeHelpFile(tool, selectedPlugin, outputFile); } private void writeHelpFile(PluginTool tool, Plugin plugin, File outputFile) throws FileNotFoundException, CancelledException { PrintWriter printWriter = new PrintWriter(outputFile); try { printWriter.println( ""); printWriter.println(""); printWriter.println(""); printWriter.println("
"); printWriter.println("\t" + ""); printWriter.println(""); printWriter.println("\t\t" + ""); printWriter.println(""); printWriter.println("
"); List"); printWriter.println(""); printWriter.println(""); } finally { printWriter.close(); } } private Listactions = getActions(tool, plugin); for (DockingActionIf action : actions) { monitor.checkCanceled(); printWriter.println("\t" + " " + action.getName() + "
"); printWriter.println("\t\t" + ""); printWriter.println(""); printWriter.println("\t\t" + ""); } printWriter.println(""); printWriter.println("