Improved CLI code.

This commit is contained in:
Christian P. MOMON 2021-05-14 17:20:52 +02:00
parent a9cf905788
commit 395b9c6034

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 Christian Pierre MOMON <christian@momon.org>
* Copyright (C) 2020-2021 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple service statistics tool.
*
@ -107,7 +107,7 @@ public final class StatoolInfosCLI
message.appendln(" statoolinfos crawl [ directory | file ]");
message.appendln(" statoolinfos htmlize [ directory | file ]");
logger.info(message.toString());
System.out.println(message.toString());
}
/**
@ -119,7 +119,7 @@ public final class StatoolInfosCLI
message.appendln(BuildInformation.instance().version());
logger.info(message.toString());
System.out.println(message.toString());
}
/**
@ -227,37 +227,6 @@ public final class StatoolInfosCLI
{
displayVersion();
}
else if (isMatching(args, "clear", "\\s*.+\\s*"))
{
Files inputs = convertPath(StringUtils.trim(args[1]));
for (File input : inputs)
{
try
{
StatoolInfos.clear(input);
}
catch (Exception exception)
{
logger.error("Error with [{}]: {}", input.getAbsoluteFile(), exception.getMessage());
}
}
}
else if (isMatching(args, "probe", "\\s*.+\\s*"))
{
Files inputs = convertPath(StringUtils.trim(args[1]));
for (File input : inputs)
{
try
{
StatoolInfos.probe(input);
}
catch (Exception exception)
{
logger.error("Error with [{}]: {}", input.getAbsoluteFile(), exception.getMessage());
exception.printStackTrace();
}
}
}
else if (isMatching(args, "build", "\\s*.+\\s*"))
{
Files inputs = convertPath(StringUtils.trim(args[1]));
@ -273,6 +242,21 @@ public final class StatoolInfosCLI
}
}
}
else if (isMatching(args, "clear", "\\s*.+\\s*"))
{
Files inputs = convertPath(StringUtils.trim(args[1]));
for (File input : inputs)
{
try
{
StatoolInfos.clear(input);
}
catch (Exception exception)
{
logger.error("Error with [{}]: {}", input.getAbsoluteFile(), exception.getMessage());
}
}
}
else if (isMatching(args, "crawl", "\\s*.+\\s*"))
{
Files inputs = convertPath(StringUtils.trim(args[1]));
@ -305,9 +289,25 @@ public final class StatoolInfosCLI
}
}
}
else if (isMatching(args, "probe", "\\s*.+\\s*"))
{
Files inputs = convertPath(StringUtils.trim(args[1]));
for (File input : inputs)
{
try
{
StatoolInfos.probe(input);
}
catch (Exception exception)
{
logger.error("Error with [{}]: {}", input.getAbsoluteFile(), exception.getMessage());
exception.printStackTrace();
}
}
}
else
{
logger.info("Bad usage.");
System.out.println("Bad usage.");
displayHelp();
}