001 // Copyright (c) 2001 Hursh Jain (http://www.mollypages.org) 002 // The Molly framework is freely distributable under the terms of an 003 // MIT-style license. For details, see the molly pages web site at: 004 // http://www.mollypages.org/. Use, modify, have fun ! 005 006 package fc.util; 007 008 import java.util.*; 009 import fc.io.*; 010 011 /** 012 Prints a welcome message along with some class loading and env. information. 013 014 If this runs properly, then you have molly! 015 */ 016 public final class Version 017 { 018 //these are/should be filled in by the build (bash) script when this is copied to the build area 019 public static final String build_version = "1.0.27"; 020 public static final String build_time = "2020-05-13 01:48"; 021 022 public static void main(String args[]) 023 { 024 Args myargs = new Args(args); 025 myargs.setUsage("java fc.util.Version [-full]"); 026 boolean full = myargs.flagExists("full"); 027 028 System.out.println("----------------------------http://mollypages.org -----------------------"); 029 System.out.println("Welcome to molly - punching your ticket to happiness!"); 030 System.out.println("This class loaded from: " + ClassUtil.getLoadedFromPath(Version.class)); 031 if (! build_version.startsWith("REPLACE_")) { 032 System.out.println("Framework version: " + build_version + "; source compiled at: " + build_time); 033 } 034 System.out.println("-------------------------------------------------------------------------"); 035 System.out.println("Use the -full flag to print out all the Java environment variables!"); 036 037 if (full) { 038 printSystemInfo(); 039 } 040 } 041 042 /** 043 Prints system env info to the console 044 */ 045 static void printSystemInfo() 046 { 047 System.out.println(); 048 System.out.println("Environment information"); 049 TablePrinter.PrintConfig config = new TablePrinter.PrintConfig(); 050 config.setCellWidthForColumn(0, 34); 051 config.setCellWidthForColumn(1, 61); 052 TablePrinter printer = new TablePrinter(2, System.out, config); 053 config.setHeader(new String[] {"Key", "Value"}); 054 055 printer.startTable(); 056 057 Properties p = System.getProperties(); 058 Enumeration e = p.propertyNames(); 059 while (e.hasMoreElements()) { 060 printer.startRow(); 061 String name = (String) e.nextElement(); 062 printer.printCell(name); 063 printer.printCell(StringUtil.viewableAscii(p.getProperty(name))); 064 printer.endRow(); 065 } 066 067 printer.endTable(); 068 } 069 070 }