Add optional flag to generate only plaintext reports instead of HTML
This commit is contained in:
parent
d4ecb34c03
commit
5a53f161e0
1 changed files with 37 additions and 3 deletions
|
@ -16,7 +16,7 @@ import 'package:libac_dart/consts.dart';
|
||||||
import 'package:libac_dart/utils/IOTools.dart';
|
import 'package:libac_dart/utils/IOTools.dart';
|
||||||
|
|
||||||
Future<int> main(List<String> args) async {
|
Future<int> main(List<String> args) async {
|
||||||
String VERSION = "1.0.082424.0744";
|
String VERSION = "1.0.082424.0751";
|
||||||
bool verbose = false;
|
bool verbose = false;
|
||||||
String HEADER =
|
String HEADER =
|
||||||
"Make File System Report\nVersion: $VERSION\nUsing LibAC Version: ${Constants.VERSION}\nAuthor: Tara Piccari\n\n";
|
"Make File System Report\nVersion: $VERSION\nUsing LibAC Version: ${Constants.VERSION}\nAuthor: Tara Piccari\n\n";
|
||||||
|
@ -36,6 +36,10 @@ Future<int> main(List<String> args) async {
|
||||||
value: "file.html",
|
value: "file.html",
|
||||||
description:
|
description:
|
||||||
"Where to place the report. If not specified, stdout is used"))
|
"Where to place the report. If not specified, stdout is used"))
|
||||||
|
.withArgument(BoolArgument(
|
||||||
|
name: "nohtml",
|
||||||
|
description:
|
||||||
|
"Disables HTML generation and uses a plain text report instead."))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
Arguments parsed = await CLIHelper.parseArgs(args, Arguments());
|
Arguments parsed = await CLIHelper.parseArgs(args, Arguments());
|
||||||
|
@ -63,8 +67,13 @@ Future<int> main(List<String> args) async {
|
||||||
|
|
||||||
if (verbose) await prnt("\r> Generating report...");
|
if (verbose) await prnt("\r> Generating report...");
|
||||||
|
|
||||||
String report =
|
String report = "";
|
||||||
|
if (!parsed.hasArg("nohtml"))
|
||||||
|
report =
|
||||||
await generateHTMLReport(FIC, ascending: ascending, VERSION: VERSION);
|
await generateHTMLReport(FIC, ascending: ascending, VERSION: VERSION);
|
||||||
|
else
|
||||||
|
report =
|
||||||
|
await generateTextReport(FIC, ascending: ascending, VERSION: VERSION);
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
StringArgument outputPath = parsed.getArg("out") as StringArgument;
|
StringArgument outputPath = parsed.getArg("out") as StringArgument;
|
||||||
|
@ -131,3 +140,28 @@ Future<String> generateHTMLReport(FileInformationCache FIC,
|
||||||
''';
|
''';
|
||||||
return header;
|
return header;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<String> generateTextReport(FileInformationCache FIC,
|
||||||
|
{bool ascending = false, String VERSION = ""}) async {
|
||||||
|
String header = '''
|
||||||
|
MKFSReport
|
||||||
|
{File System Report}
|
||||||
|
Generated by mkfsreport v${VERSION}
|
||||||
|
Bundled LibAC Version: ${Constants.VERSION} [https://git.zontreck.com/AriasCreations/LibAC-dart]
|
||||||
|
|
||||||
|
MKFSREPORT and LibAC are provided free of charge with no implied warranties. The software is provided as-is.
|
||||||
|
|
||||||
|
This program was created by Tara Piccari, as a part of the Aria's Creations common code library as a helper utility.
|
||||||
|
Aria's Creations is a alias for online-only works. Aria is an anagram derived from my name. piccARI, tarA. You place my last name first, take the last 3, skip the first 3 in my first name and take the remaining character(s) and you have my alias.
|
||||||
|
|
||||||
|
This utility analyzed the specified folder path to generate a detailed report of directory and file sizes as seen below.
|
||||||
|
''';
|
||||||
|
|
||||||
|
for (var entry in (await FIC.getOrderedList(ascending: ascending))) {
|
||||||
|
header += '''
|
||||||
|
${entry.isFile ? "FILE" : "DIR"} ${entry.toString()} ${entry.path}
|
||||||
|
''';
|
||||||
|
}
|
||||||
|
|
||||||
|
return header;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue