- if (process.argv.indexOf("--help") >= 0) {
- [
- "",
- " [b]findGravityRegions.js originally intended[/b] to generate [b]vertex sequences[/b] for zero-gravity outlines, but now can trace outlines for any given tile.", "",
- " required argument: tile target, e.g. 3 to outline all sections of tile type 3", "",
- " optional flag: --invert to outline regions that are NOT the provided tile type (e.g. used to generate full-level outlines",
- ""
- ].forEach(function(s) {
- // consistent indentation
- var shouldIndent = (s.substr(0, 2) === " "),
- indentString = "";
- while (s.substr(0, 2) === " ") {
- indentString += " ";
- s = s.substr(2);
- }
- var isBold = false;
- words = s.split(" ");
- var buffer = shouldIndent ? indentString : "",
- charsUsed = 0;
- while (words.length > 0) {
- var nextWord = words.splice(0, 1)[0] + " ",
- nextWordLength = nextWord.replace("[b]", "").replace("[/b]").length;
- // enable bold
- if (nextWord.substr(0, 3) === "[b]") {
- isBold = true;
- nextWord = "\x1b[1m" + nextWord.substr(3);
- }
- if (charsUsed + nextWordLength < 75) {
- buffer += nextWord;
- charsUsed += nextWordLength;
- // disable bold?
- if (nextWord.substr(nextWord.length - 5, 4) === "[/b]") {
- isBold = false;
- buffer = buffer.substr(0, buffer.length - 5) + " " + "\x1b[0m";
- }
- } else {
- console.log(buffer);
- buffer = (shouldIndent ? indentString : "") + nextWord;
- charsUsed = (shouldIndent ? indentString.length : 0) + nextWordLength;
- if (isBold) {
- buffer = "\x1b[1m" + buffer;
- }
- // disable bold?
- if (nextWord.substr(nextWord.length - 5, 4) === "[/b]") {
- isBold = false;
- buffer = buffer.substr(0, buffer.length - 5) + " " + "\x1b[0m";
- }
- }
- }
- // remainder
- if (buffer.length > 0)
- console.log(buffer);
- else
- console.log("");
- });
- process.exit(0);
- }