diff --git a/dart/bin/dart.dart b/dart/bin/dart.dart deleted file mode 100644 index 564e1f2..0000000 --- a/dart/bin/dart.dart +++ /dev/null @@ -1,61 +0,0 @@ -import 'package:args/args.dart'; - -const String version = '0.0.1'; - -ArgParser buildParser() { - return ArgParser() - ..addFlag( - 'help', - abbr: 'h', - negatable: false, - help: 'Print this usage information.', - ) - ..addFlag( - 'verbose', - abbr: 'v', - negatable: false, - help: 'Show additional command output.', - ) - ..addFlag( - 'version', - negatable: false, - help: 'Print the tool version.', - ); -} - -void printUsage(ArgParser argParser) { - print('Usage: dart dart.dart [arguments]'); - print(argParser.usage); -} - -void main(List arguments) { - final ArgParser argParser = buildParser(); - try { - final ArgResults results = argParser.parse(arguments); - bool verbose = false; - - // Process the parsed arguments. - if (results.wasParsed('help')) { - printUsage(argParser); - return; - } - if (results.wasParsed('version')) { - print('dart version: $version'); - return; - } - if (results.wasParsed('verbose')) { - verbose = true; - } - - // Act on the arguments provided. - print('Positional arguments: ${results.rest}'); - if (verbose) { - print('[VERBOSE] All arguments: ${results.arguments}'); - } - } on FormatException catch (e) { - // Print usage information if an invalid argument was provided. - print(e.message); - print(''); - printUsage(argParser); - } -} diff --git a/dart/bin/dbikc.dart b/dart/bin/dbikc.dart new file mode 100644 index 0000000..23fce64 --- /dev/null +++ b/dart/bin/dbikc.dart @@ -0,0 +1,31 @@ +import 'dart:io'; + +import 'package:libac_dart/argparse/Args.dart'; +import 'package:libac_dart/argparse/Builder.dart'; +import 'package:libac_dart/argparse/CLIHelper.dart'; +import 'package:libac_dart/argparse/types/Bool.dart'; +import 'package:libac_dart/argparse/types/String.dart'; +import 'package:libac_dart/utils/DBIKC.dart'; + +Future main(List args) async { + Arguments defaults = ArgumentsBuilder.builder() + .withArgument(StringArgument( + name: "value", value: "", description: "Text to encode/decode")) + .withArgument(BoolArgument(name: "help", description: "This help text")) + .build(); + + var helpText = CLIHelper.makeArgCLIHelp(defaults); + var HEADER = "Double Breasted Interrupted Key Cipher\nVersion: 1.0\n\n"; + + Arguments parsed = await CLIHelper.parseArgs(args, Arguments()); + if (parsed.hasArg("help") || !parsed.hasArg("value")) { + print("${HEADER}${helpText}"); + exit(0); + return 0; + } else { + print(DoubleBreastedInterruptedKeyCipher.encode( + parsed.getArg("value")!.getValue())); + } + + return 0; +} diff --git a/dart/bin/mkfsreport.dart b/dart/bin/mkfsreport.dart new file mode 100644 index 0000000..3d6ce49 --- /dev/null +++ b/dart/bin/mkfsreport.dart @@ -0,0 +1,165 @@ +/* + Make File System Report + + This tool will generate a HTML report for the base path specified. + */ + +import 'dart:io'; + +import 'package:libac_dart/argparse/Args.dart'; +import 'package:libac_dart/argparse/Builder.dart'; +import 'package:libac_dart/argparse/CLIHelper.dart'; +import 'package:libac_dart/argparse/types/Bool.dart'; +import 'package:libac_dart/argparse/types/String.dart'; +import 'package:libac_dart/consts.dart'; +import 'package:libac_dart/utils/IOTools.dart'; + +Future main(List args) async { + String VERSION = "1.0.082424.0758"; + bool verbose = false; + String HEADER = + "Make File System Report\nVersion: $VERSION\nUsing LibAC Version: ${Constants.VERSION}\nAuthor: Tara Piccari\n\n"; + + Arguments defaults = ArgumentsBuilder.builder() + .withArgument(BoolArgument( + name: "asc", + description: "Operate in ascending mode, smallest size listed first")) + .withArgument(StringArgument( + name: "path", + value: "/", + description: "The path to generate a report for")) + .withArgument( + BoolArgument(name: "help", description: "Hey look! It's me!")) + .withArgument(StringArgument( + name: "out", + value: "file.html", + description: + "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(); + + Arguments parsed = await CLIHelper.parseArgs(args, Arguments()); + String helpTest = "$HEADER${CLIHelper.makeArgCLIHelp(defaults)}"; + + if (parsed.count == 0 || !parsed.hasArg("path") || parsed.hasArg("help")) { + print(helpTest); + return 0; + } else { + if (parsed.hasArg("out")) + verbose = true; + else + verbose = false; + } + print(HEADER); + + bool ascending = false; + if (parsed.hasArg("asc")) ascending = true; + StringArgument pathArg = parsed.getArg("path") as StringArgument; + if (verbose) print("> Analyzing files..."); + + await getDirectorySize(pathArg.value, + cacheSize: true, recursive: true, verbose: parsed.hasArg("o")); + FileInformationCache FIC = FileInformationCache.obtain(); + + if (verbose) await prnt("\r> Generating report..."); + + String report = ""; + if (!parsed.hasArg("nohtml")) + report = + await generateHTMLReport(FIC, ascending: ascending, VERSION: VERSION); + else + report = + await generateTextReport(FIC, ascending: ascending, VERSION: VERSION); + + if (verbose) { + StringArgument outputPath = parsed.getArg("out") as StringArgument; + await prnt("\n> Saving report..."); + await File(outputPath.value).writeAsString(report); + await prnt("\n> Task Completed\n"); + + var size = await File(outputPath.value).length(); + FileInfo savedFile = + FileInfo(path: outputPath.value, size: size, isFile: true); + await prnt("> Report file size: ${savedFile.toString()}\n\n"); + } else { + print(report); + } + + return 0; +} + +Future generateHTMLReport(FileInformationCache FIC, + {bool ascending = false, String VERSION = ""}) async { + String header = ''' + + MKFSReport + +

File System Report


+ Generated by mkfsreport v${VERSION}
+ Bundled LibAC Version: ${Constants.VERSION}
+
+    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.
+    

+ '''; + + header += ''' + + + + + + + '''; + + for (var entry in (await FIC.getOrderedList(ascending: ascending))) { + header += ''' + + + + + + '''; + } + + header += ''' +
TypePathSize
${entry.isFile ? "FILE" : "DIR"}${entry.path}${entry.toString()}
+ '''; + + header += ''' + + + '''; + return header; +} + +Future 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.\n +'''; + + for (var entry in (await FIC.getOrderedList(ascending: ascending))) { + header += + " ${entry.isFile ? "FILE" : "DIR"} ${entry.toString()} ${entry.path}\n"; + } + + return header; +} diff --git a/dart/bin/nbt2snbt.dart b/dart/bin/nbt2snbt.dart new file mode 100644 index 0000000..aaf536b --- /dev/null +++ b/dart/bin/nbt2snbt.dart @@ -0,0 +1,51 @@ +import 'dart:io'; + +import 'package:libac_dart/argparse/Args.dart'; +import 'package:libac_dart/argparse/Builder.dart'; +import 'package:libac_dart/argparse/CLIHelper.dart'; +import 'package:libac_dart/argparse/types/Bool.dart'; +import 'package:libac_dart/argparse/types/String.dart'; +import 'package:libac_dart/nbt/NbtIo.dart'; +import 'package:libac_dart/nbt/SnbtIo.dart'; +import 'package:libac_dart/nbt/impl/CompoundTag.dart'; +import 'package:nbteditor/Consts2.dart'; + +const HEADER = + "nbt2snbt\nCopyright Piccari Creations 2024 - Tara Piccari\nVersion: $VERSION\nPurpose: Converts Named Binary Tag files to a more readable Stringified version\n\n"; +void main(List args) async { + Arguments usage = ArgumentsBuilder.builder() + .withArgument( + BoolArgument(name: "help", description: "Print this output")) + .withArgument(StringArgument( + name: "input", value: "%", description: "The input file to convert")) + .withArgument(StringArgument( + name: "out", + value: "%", + description: + "The path to the output file. If not supplied, STDOUT is used.")) + .build(); + + Arguments defaults = Arguments(); + Arguments vArgs = await CLIHelper.parseArgs(args, defaults); + + if (vArgs.hasArg("help") || vArgs.count == 0) { + print(HEADER); + print(CLIHelper.makeArgCLIHelp(usage)); + } else { + if (!vArgs.hasArg("input")) { + print(HEADER); + print("Missing required argument: input"); + exit(1); + } + String file = vArgs.getArg("input")!.getValue() as String; + + CompoundTag ct = await NbtIo.read(file); + + if (!vArgs.hasArg("out")) { + print(SnbtIo.writeToString(ct)); + } else { + SnbtIo.writeToFile(vArgs.getArg("out")!.getValue() as String, ct); + print("Wrote SNBT output to file"); + } + } +} diff --git a/dart/bin/snbt2nbt.dart b/dart/bin/snbt2nbt.dart new file mode 100644 index 0000000..a43b7ef --- /dev/null +++ b/dart/bin/snbt2nbt.dart @@ -0,0 +1,56 @@ +import 'dart:io'; + +import 'package:libac_dart/argparse/Args.dart'; +import 'package:libac_dart/argparse/Builder.dart'; +import 'package:libac_dart/argparse/CLIHelper.dart'; +import 'package:libac_dart/argparse/types/Bool.dart'; +import 'package:libac_dart/argparse/types/String.dart'; +import 'package:libac_dart/nbt/NbtIo.dart'; +import 'package:libac_dart/nbt/SnbtIo.dart'; +import 'package:libac_dart/nbt/impl/CompoundTag.dart'; +import 'package:nbteditor/Consts2.dart'; + +const HEADER = + "snbt2nbt\nCopyright Piccari Creations 2024 - Tara Piccari\nVersion: $VERSION\nPurpose: Converts the more readable stringified NBT to Named Binary Tag format\n\n"; +void main(List args) async { + Arguments usage = ArgumentsBuilder.builder() + .withArgument( + BoolArgument(name: "help", description: "Print this output")) + .withArgument(StringArgument( + name: "input", value: "%", description: "The input file to convert")) + .withArgument(StringArgument( + name: "out", value: "%", description: "The path to the output file.")) + .withArgument(BoolArgument( + name: "compress", + description: "If supplied, compresses the output file")) + .build(); + + Arguments defaults = Arguments(); + Arguments vArgs = await CLIHelper.parseArgs(args, defaults); + + if (vArgs.hasArg("help") || vArgs.count == 0) { + print(HEADER); + print(CLIHelper.makeArgCLIHelp(usage)); + } else { + if (!vArgs.hasArg("input")) { + print(HEADER); + print("Missing required argument: input"); + exit(1); + } + String file = vArgs.getArg("input")!.getValue() as String; + + CompoundTag ct = await SnbtIo.readFromFile(file) as CompoundTag; + + if (!vArgs.hasArg("out")) { + print("Missing required argument: out"); + exit(2); + } else { + if (!vArgs.hasArg("compress")) { + NbtIo.write(vArgs.getArg("out")!.getValue() as String, ct); + } else { + NbtIo.writeCompressed(vArgs.getArg("out")!.getValue() as String, ct); + } + print("Wrote NBT output to file"); + } + } +} diff --git a/dart/bin/uuidgen.dart b/dart/bin/uuidgen.dart new file mode 100644 index 0000000..ece56a9 --- /dev/null +++ b/dart/bin/uuidgen.dart @@ -0,0 +1,6 @@ +import 'package:libac_dart/utils/uuid/UUID.dart'; + +void main() { + UUID id = UUID.generate(4); + print(id.toString()); +} \ No newline at end of file