/// <summary> /// given input contents, parse it, and return a ScriptData object /// this can throw /// </summary> /// <param name="inputContents">The Bash File or JSON file contents</param> /// <returns></returns> private static ScriptData FromFileContents(string inputContents) { if (inputContents == "") { throw new ArgumentException("The file is empty"); } ScriptData scriptData = null; // is it bash, json, or trash? // bw scripts start with # and JSON with { switch (inputContents[0]) { case '#': { // treat like a Bash Wizard shell script - parse it and echo out a new bash script scriptData = ScriptData.FromBash(inputContents); } break; case '{': { // treat like a JSON file - echo out a new bash script based on the JSON scriptData = ScriptData.FromJson(inputContents, ""); } break; default: throw new Exception($"The input is not a JSON file or a Bash Wizard File because the first character is {inputContents[0]} instead of a # or a {{"); } return(scriptData); }