Skip to content

Commit 5eba86d

Browse files
committed
+ Add --version option to retrieve magic library version
1 parent 42ac72a commit 5eba86d

File tree

1 file changed

+39
-0
lines changed
  • file/src/main/java/org/magicdb/magic/application

1 file changed

+39
-0
lines changed

file/src/main/java/org/magicdb/magic/application/Main.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,36 @@ private static void extractRecursive(IdentifierMagicDB extractor, Configuration
225225

226226
}
227227

228+
/**
229+
* Display (to standard output) package details for provided Package.
230+
*
231+
* @param pkg Package whose details need to be printed to standard output.
232+
*/
233+
private static void displayPackageDetails(final Package pkg)
234+
{
235+
final String name = pkg.getName();
236+
System.out.println(name);
237+
System.out.println("\tSpec Title/Version: " + pkg.getSpecificationTitle() + " " + pkg.getSpecificationVersion());
238+
System.out.println("\tSpec Vendor: " + pkg.getSpecificationVendor()); System.out.println("\tImplementation: " + pkg.getImplementationTitle() + " " + pkg.getImplementationVersion());
239+
240+
System.out.println("\tImplementation: " + pkg.getImplementationTitle() + " " + pkg.getImplementationVersion());
241+
System.out.println("\tImplementation Vendor: " + pkg.getImplementationVendor());
242+
}
243+
244+
245+
private static void dumpPackageInformation()
246+
{
247+
final Package[] packages = Package.getPackages();
248+
for (final Package pkg : packages)
249+
{
250+
final String name = pkg.getName();
251+
if ( !name.startsWith("sun") && !name.startsWith("java"))
252+
{
253+
displayPackageDetails(pkg);
254+
}
255+
}
256+
}
257+
228258
/** Process command line parameters and return configuration
229259
* information
230260
*
@@ -244,6 +274,7 @@ private static void processParameters(Configuration config, String[] args)
244274
System.out.println(" -r : Recursively scan directories");
245275
System.out.println(" -d : Debug mode");
246276
System.out.println(" -cb : Check brief (less verbose)");
277+
System.out.println(" --version : Return version information on library");
247278
System.out
248279
.println(" filespec : Filemask and directory specification where to scan");
249280
System.out.println("Built in plugins");
@@ -259,6 +290,14 @@ else if (args[i].equals("-d"))
259290
config.debug = true;
260291
else if (args[i].equals("-cb"))
261292
config.brief = true;
293+
else if (args[i].equals("--version"))
294+
{
295+
// Return information on the magic library implementation */
296+
Package magicLibraryPackage = org.magicdb.magic.IdentifierMagicDB.class.getPackage();
297+
System.out.println(magicLibraryPackage.getImplementationTitle() + " " + magicLibraryPackage.getImplementationVersion());
298+
System.exit(0);
299+
}
300+
262301
}
263302

264303
if (config.debug)

0 commit comments

Comments
 (0)