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
006package fc.util;
007
008import java.util.*;
009import fc.io.*;
010
011/**
012Prints a welcome message along with some class loading and env. information.
013
014If this runs properly, then you have molly!
015*/
016public final class Version 
017{
018//these are/should be filled in by the build (bash) script when this is copied to the build area
019public static final String build_version = "1.0.29";
020public static final String build_time  = "2024-03-06 20:19";
021
022public 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/**
043Prints system env info to the console
044*/
045static void printSystemInfo() 
046  { 
047  System.out.println();
048  System.out.println("Environment information");
049  TablePrinter.PrintConfig config = new TablePrinter.PrintConfig();
050  int cols = MiscUtil.getTerminalColumnCount();
051  int firstcol = 34;
052  int secondcol = 61;
053  if (cols != -1) {
054    cols = cols/3;
055    firstcol = cols - 10; 
056    secondcol = cols*2 - 10; 
057    System.out.println(firstcol + "," + secondcol);
058    }
059
060  config.setCellWidthForColumn(0, firstcol);
061  config.setCellWidthForColumn(1, secondcol);
062  TablePrinter printer = new TablePrinter(2, System.out, config);
063  config.setHeader(new String[] {"Key", "Value"});
064
065  printer.startTable();
066  
067  Properties p = System.getProperties();
068  Enumeration e = p.propertyNames();
069  while (e.hasMoreElements()) {
070    printer.startRow();
071    String name = (String) e.nextElement();   
072    printer.printCell(name);
073    printer.printCell(StringUtil.viewableAscii(p.getProperty(name)));
074    printer.endRow(); 
075    } 
076    
077  printer.endTable();
078  }
079
080}