本文整理匯總了Java中com.trollworks.toolkit.utility.cmdline.CmdLineOption類的典型用法代碼示例。如果您正苦於以下問題:Java CmdLineOption類的具體用法?Java CmdLineOption怎麽用?Java CmdLineOption使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
CmdLineOption類屬於com.trollworks.toolkit.utility.cmdline包,在下文中一共展示了CmdLineOption類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import com.trollworks.toolkit.utility.cmdline.CmdLineOption; //導入依賴的package包/類
/** Utility for creating GCS's icon sets. */
public static void main(String[] args) {
String name = "GenerateIcons";
Attributes attributes = new Attributes();
attributes.putValue(BundleInfo.BUNDLE_NAME, name);
attributes.putValue(BundleInfo.BUNDLE_VERSION, "1.0");
attributes.putValue(BundleInfo.BUNDLE_COPYRIGHT_OWNER, "Richard A. Wilkes");
attributes.putValue(BundleInfo.BUNDLE_COPYRIGHT_YEARS, "2014");
attributes.putValue(BundleInfo.BUNDLE_LICENSE, "Mozilla Public License 2.0");
BundleInfo.setDefault(new BundleInfo(attributes, name));
CmdLineOption icnsOption = new CmdLineOption("Generate ICNS files", null, "icns");
CmdLineOption icoOption = new CmdLineOption("Generate ICO files", null, "ico");
CmdLineOption appOption = new CmdLineOption("Generate just the 128x128 app icon", null, "app");
CmdLineOption dirOption = new CmdLineOption("The directory to place the generated files into", "DIR", "dir");
CmdLine cmdline = new CmdLine();
cmdline.addOptions(icnsOption, icoOption, appOption, dirOption);
cmdline.processArguments(args);
boolean icns = cmdline.isOptionUsed(icnsOption);
boolean ico = cmdline.isOptionUsed(icoOption);
boolean app = cmdline.isOptionUsed(appOption);
if (!icns && !ico && !app) {
System.err.printf("At least one of %s, %s, or %s must be specified.\n", icnsOption, icoOption, appOption);
System.exit(1);
}
try {
File dir = new File(cmdline.isOptionUsed(dirOption) ? cmdline.getOptionArgument(dirOption) : ".");
System.out.println("Generating icons into " + dir);
dir.mkdirs();
if (app) {
File file = new File(dir, "gcs.png");
if (StdImage.writePNG(file, getAppIcons().getImage(128), 72)) {
System.out.println("Created: " + file);
} else {
System.err.println("Unable to create: " + file);
}
}
if (icns || ico) {
createIconFiles(getAppIcons(), dir, "app", icns, ico);
createIconFiles(getAdvantagesDocumentIcons(), dir, AdvantageList.EXTENSION, icns, ico);
createIconFiles(getEquipmentDocumentIcons(), dir, EquipmentList.EXTENSION, icns, ico);
createIconFiles(getCharacterSheetDocumentIcons(), dir, GURPSCharacter.EXTENSION, icns, ico);
createIconFiles(getTemplateDocumentIcons(), dir, Template.EXTENSION, icns, ico);
createIconFiles(getSkillsDocumentIcons(), dir, SkillList.EXTENSION, icns, ico);
createIconFiles(getSpellsDocumentIcons(), dir, SpellList.EXTENSION, icns, ico);
createIconFiles(getPDFDocumentIcons(), dir, FileType.PDF_EXTENSION, icns, ico);
}
} catch (Exception exception) {
exception.printStackTrace(System.err);
}
}