(CommandList children: [ (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:currentVersion) op:Equal rhs:{(DQ (1.11.1))} spids:[7])] spids: [7] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:LANG) op: Equal rhs: { (DQ (BracedVarSub token: <VSub_Name LANG> suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(en)}) spids: [17 21] ) ) } spids: [15] ) ] spids: [15] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:locale) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [(C {(echo)} {($ VSub_Name "$LANG")}) (C {(cut)} {(-c1-2)})] negated: False ) ] ) left_token: <Left_CommandSub "$("> spids: [25 35] ) } spids: [24] ) ] spids: [24] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:configuredClient) op:Equal rhs:{(DQ )} spids:[37])] spids: [37] ) (FuncDef name: getConfiguredClient body: (BraceGroup children: [ (If arms: [ (if_arm cond: [ (Sentence child: (C {(command)} {(-v)} {(curl)}) terminator: <Op_Amp "&"> ) (Sentence child: (SimpleCommand redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(/dev/null)} spids: [61] ) ] ) terminator: <Op_Semi ";"> ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:configuredClient) op: Equal rhs: {(DQ (curl))} spids: [69] ) ] spids: [69] ) ] spids: [-1 66] ) (if_arm cond: [ (Sentence child: (C {(command)} {(-v)} {(wget)}) terminator: <Op_Amp "&"> ) (Sentence child: (SimpleCommand redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(/dev/null)} spids: [84] ) ] ) terminator: <Op_Semi ";"> ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:configuredClient) op: Equal rhs: {(DQ (wget))} spids: [92] ) ] spids: [92] ) ] spids: [75 89] ) (if_arm cond: [ (Sentence child: (C {(command)} {(-v)} {(fetch)}) terminator: <Op_Amp "&"> ) (Sentence child: (SimpleCommand redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(/dev/null)} spids: [107] ) ] ) terminator: <Op_Semi ";"> ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:configuredClient) op: Equal rhs: {(DQ (fetch))} spids: [115] ) ] spids: [115] ) ] spids: [98 112] ) ] else_action: [ (C {(echo)} {(DQ ("Error: This tool reqires either curl, wget, or fetch to be installed."))} ) (ControlFlow token:<ControlFlow_Return return> arg_word:{(1)}) ] spids: [121 136] ) ] spids: [49] ) spids: [45 48] ) (FuncDef name: httpGet body: (BraceGroup children: [ (Case to_match: {(DQ ($ VSub_Name "$configuredClient"))} arms: [ (case_arm pat_list: [{(curl)}] action: [(C {(curl)} {(-A)} {(curl)} {(-s)} {(DQ ($ VSub_At "$@"))})] spids: [161 162 175 -1] ) (case_arm pat_list: [{(wget)}] action: [(C {(wget)} {(-qO-)} {(DQ ($ VSub_At "$@"))})] spids: [178 179 188 -1] ) (case_arm pat_list: [{(fetch)}] action: [(C {(fetch)} {(-o)} {(DQ (...))})] spids: [191 192 201 -1] ) ] spids: [152 158 204] ) ] spids: [149] ) spids: [145 148] ) (FuncDef name: getIPWeather body: (BraceGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:country) op: Equal rhs: { (CommandSubPart command_list: (CommandList children:[(C {(httpGet)} {(ipinfo.io/country)})]) left_token: <Left_CommandSub "$("> spids: [218 222] ) } spids: [217] ) ] spids: [217] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Name "$country")} right: {(DQ (US))} ) ) terminator: <Op_Semi ";"> ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:city) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [(C {(httpGet)} {(ipinfo.io/city)})] ) left_token: <Left_CommandSub "$("> spids: [253 257] ) } spids: [252] ) ] spids: [252] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:region) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [(C {(httpGet)} {(ipinfo.io/region)})] ) left_token: <Left_CommandSub "$("> spids: [265 269] ) } spids: [264] ) ] spids: [264] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:region) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(echo)} {(DQ ($ VSub_Name "$region"))}) (C {(tr)} {(-dc)} {(SQ <"[:upper:]">)}) ] negated: False ) ] ) left_token: <Left_CommandSub "$("> spids: [277 293] ) } spids: [276] ) ] spids: [276] ) (C {(httpGet)} {($ VSub_Name "$locale") (.wttr.in/) ($ VSub_Name "$city") (Lit_Comma ",") ($ VSub_Name "$region") ($ VSub_Number "$1") } ) ] spids: [-1 246] ) ] else_action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:location) op: Equal rhs: { (CommandSubPart command_list: (CommandList children:[(C {(httpGet)} {(ipinfo.io/loc)})]) left_token: <Left_CommandSub "$("> spids: [313 317] ) } spids: [312] ) ] spids: [312] ) (C {(httpGet)} {($ VSub_Name "$locale") (.wttr.in/) ($ VSub_Name "$location") ($ VSub_Number "$1")} ) ] spids: [306 332] ) ] spids: [214] ) spids: [210 213] ) (FuncDef name: getLocationWeather body: (BraceGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:args) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(echo)} {(DQ ($ VSub_At "$@"))}) (C {(tr)} {(DQ (" "))} {(Lit_Other "+")}) ] negated: False ) ] ) left_token: <Left_CommandSub "$("> spids: [345 362] ) } spids: [344] ) ] spids: [344] ) (C {(httpGet)} {($ VSub_Name "$locale") (.wttr.in/) (${ VSub_Name args)}) ] spids: [341] ) spids: [337 340] ) (FuncDef name: checkInternet body: (BraceGroup children: [ (Pipeline children: [ (C {(echo)} { (DQ ("GET http://google.com HTTP/1.0") (EscapedLiteralPart token:<Lit_EscapedChar "\\n">) (EscapedLiteralPart token:<Lit_EscapedChar "\\n">) ) } ) (SimpleCommand words: [{(nc)} {(google.com)} {(80)}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(/dev/null)} spids: [399] ) (Redir op_id:Redir_GreatAnd fd:2 arg_word:{(1)} spids:[403]) ] ) ] negated: False ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {($ VSub_QMark "$?")} {(-eq)} {(0)} {(Lit_Other "]")}) terminator: <Op_Semi ";"> ) ] action: [(ControlFlow token:<ControlFlow_Return return> arg_word:{(0)})] spids: [-1 423] ) ] else_action: [ (SimpleCommand words: [{(echo)} {(DQ ("Error: no active internet connection"))}] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[443])] ) (ControlFlow token:<ControlFlow_Return return> arg_word:{(1)}) ] spids: [434 455] ) ] spids: [380] ) spids: [376 379] ) (FuncDef name: update body: (BraceGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:repositoryName) op: Equal rhs: {(DQ (Bash-Snippets))} spids: [479] ) ] spids: [479] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:githubUserName) op: Equal rhs: {(DQ (alexanderepstein))} spids: [488] ) ] spids: [488] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:nameOfInstallFile) op: Equal rhs: {(DQ (install.sh))} spids: [497] ) ] spids: [497] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:latestVersion) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(httpGet)} {(https) (Lit_Other ":") (//api.github.com/repos/) ($ VSub_Name "$githubUserName") (/) ($ VSub_Name "$repositoryName") (/tags) } ) (C {(grep)} {(-Eo)} {(SQ <"\"name\":.*?[^\\\\]\",">)}) (C {(head)} {(-1)}) (C {(grep)} {(-Eo)} {(DQ ("[0-9.]+"))}) ] negated: False ) ] ) left_token: <Left_CommandSub "$("> spids: [507 543] ) } spids: [506] ) ] spids: [506] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (LogicalOr left: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Name "$currentVersion")} right: {(DQ )} ) right: (LogicalOr left: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Name "$repositoryName")} right: {(DQ )} ) right: (LogicalOr left: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Name "$githubUserName")} right: {(DQ )} ) right: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Name "$nameOfInstallFile")} right: {(DQ )} ) ) ) ) ) terminator: <Op_Semi ";"> ) ] action: [ (SimpleCommand words: [ {(echo)} {(DQ ("Error: update utility has not been configured correctly."))} ] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[599])] ) (C {(exit)} {(1)}) ] spids: [-1 590] ) (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Name "$latestVersion")} right: {(DQ )} ) ) terminator: <Op_Semi ";"> ) ] action: [ (SimpleCommand words: [{(echo)} {(DQ ("Error: no active internet connection"))}] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[630])] ) (C {(exit)} {(1)}) ] spids: [608 621] ) ] else_action: [ (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobNEqual left: {(DQ ($ VSub_Name "$latestVersion"))} right: {(DQ ($ VSub_Name "$currentVersion"))} ) ) terminator: <Op_Semi ";"> ) ] action: [ (C {(echo)} {(DQ ("Version ") ($ VSub_Name "$latestVersion") (" available"))}) (C {(echo)} {(-n)} { (DQ ("Do you wish to update ") ($ VSub_Name "$repositoryName") (" [Y/n]: ")) } ) (C {(read)} {(-r)} {(answer)}) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (LogicalOr left: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(DQ ($ VSub_Name "$answer"))} right: {(DQ (Y))} ) right: (BoolBinary op_id: BoolBinary_GlobDEqual left: {(DQ ($ VSub_Name "$answer"))} right: {(DQ (y))} ) ) ) terminator: <Op_Semi ";"> ) ] action: [ (AndOr children: [ (C {(cd)} {(TildeSubPart prefix:"")}) (BraceGroup children: [ (Sentence child: (C {(echo)} {(SQ <"Update Failed">)}) terminator: <Op_Semi ";"> ) (Sentence child: (C {(exit)} {(1)}) terminator: <Op_Semi ";"> ) ] spids: [727] ) ] op_id: Op_DPipe ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolUnary op_id: BoolUnary_d child: {(Lit_Tilde "~") (/) ($ VSub_Name "$repositoryName") } ) ) terminator: <Op_Semi ";"> ) ] action: [ (Sentence child: (AndOr children: [ (C {(rm)} {(-r)} {(-f)} {($ VSub_Name "$repositoryName")}) (BraceGroup children: [ (Sentence child: (C {(echo)} { (DQ ( "Permissions Error: try running the update as sudo" ) ) } ) terminator: <Op_Semi ";"> ) (Sentence child: (C {(exit)} {(1)}) terminator: <Op_Semi ";"> ) ] spids: [771] ) ] op_id: Op_DPipe ) terminator: <Op_Semi ";"> ) ] spids: [-1 759] ) ] spids: [-1 789] ) (AndOr children: [ (C {(git)} {(clone)} { (DQ ("https://github.com/") ($ VSub_Name "$githubUserName") (/) ($ VSub_Name "$repositoryName") ) } ) (BraceGroup children: [ (Sentence child: (C {(echo)} {(DQ ("Couldn't download latest version"))}) terminator: <Op_Semi ";"> ) (Sentence child: (C {(exit)} {(1)}) terminator: <Op_Semi ";"> ) ] spids: [805] ) ] op_id: Op_DPipe ) (AndOr children: [ (C {(cd)} {($ VSub_Name "$repositoryName")}) (BraceGroup children: [ (Sentence child: (C {(echo)} {(SQ <"Update Failed">)}) terminator: <Op_Semi ";"> ) (Sentence child: (C {(exit)} {(1)}) terminator: <Op_Semi ";"> ) ] spids: [829] ) ] op_id: Op_DPipe ) (AndOr children: [ (SimpleCommand words: [ {(git)} {(checkout)} {(DQ (v) ($ VSub_Name "$latestVersion"))} ] redirects: [ (Redir op_id: Redir_Great fd: 2 arg_word: {(/dev/null)} spids: [856] ) ] ) (AndOr children: [ (SimpleCommand words: [ {(git)} {(checkout)} {(DQ ($ VSub_Name "$latestVersion"))} ] redirects: [ (Redir op_id: Redir_Great fd: 2 arg_word: {(/dev/null)} spids: [870] ) ] ) (C {(echo)} { (DQ ( "Couldn't git checkout to stable release, updating to latest commit." ) ) } ) ] op_id: Op_DPipe ) ] op_id: Op_DPipe ) (C {(chmod)} {(a) (Lit_Other "+") (x)} {(install.sh)}) (AndOr children: [ (C {(./) ($ VSub_Name "$nameOfInstallFile")} {(DQ (update))}) (C {(exit)} {(1)}) ] op_id: Op_DPipe ) (C {(cd)} {(..)}) (AndOr children: [ (C {(rm)} {(-r)} {(-f)} {($ VSub_Name "$repositoryName")}) (BraceGroup children: [ (Sentence child: (C {(echo)} { (DQ ( "Permissions Error: update succesfull but cannot delete temp files located at ~/" ) ($ VSub_Name "$repositoryName") (" delete this directory with sudo") ) } ) terminator: <Op_Semi ";"> ) (Sentence child: (C {(exit)} {(1)}) terminator: <Op_Semi ";"> ) ] spids: [924] ) ] op_id: Op_DPipe ) ] spids: [-1 718] ) ] else_action: [(C {(exit)} {(1)})] spids: [943 951] ) ] spids: [-1 659] ) ] else_action: [ (C {(echo)} {(DQ ($ VSub_Name "$repositoryName") (" is already the latest version"))} ) ] spids: [954 965] ) ] spids: [639 968] ) ] spids: [464] ) spids: [460 463] ) (FuncDef name: usage body: (BraceGroup children: [ (C {(echo)} {(DQ (Weather))}) (C {(echo)} { (DQ ( "Description: Provides a 3 day forecast on your current location or a specified location." ) ) } ) (C {(echo)} {(DQ (" With no flags Weather will default to your current location."))}) (C {(echo)} { (DQ ( "Usage: weather or weather [flag] or weather [country] or weather [city] [state]" ) ) } ) (C {(echo)} {(DQ (" weather [i] get weather in imperial units"))}) (C {(echo)} {(DQ (" weather [m] get weather in metric units"))}) (C {(echo)} {(DQ (" weather [Moon] grabs the phase of the moon"))}) (C {(echo)} {(DQ (" -u Update Bash-Snippet Tools"))}) (C {(echo)} {(DQ (" -h Show the help"))}) (C {(echo)} {(DQ (" -v Get the tool version"))}) (C {(echo)} {(DQ ("Examples:"))}) (C {(echo)} {(DQ (" weather"))}) (C {(echo)} {(DQ (" weather Tokyo"))}) (C {(echo)} {(DQ (" weather Moon"))}) (C {(echo)} {(DQ (" weather m"))}) ] spids: [978] ) spids: [974 977] ) (AndOr children:[(C {(getConfiguredClient)})(C {(exit)} {(1)})] op_id:Op_DPipe) (AndOr children:[(C {(checkInternet)})(C {(exit)} {(1)})] op_id:Op_DPipe) (While cond: [(Sentence child:(C {(getopts)} {(DQ (uvh))} {(opt)}) terminator:<Op_Semi ";">)] body: (DoGroup children: [ (Case to_match: {($ VSub_Name "$opt")} arms: [ (case_arm pat_list: [{(EscapedLiteralPart token:<Lit_EscapedChar "\\?">)}] action: [ (SimpleCommand words: [{(echo)} {(DQ ("Invalid option: -") ($ VSub_Name "$OPTARG"))}] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[1143])] ) (C {(exit)} {(1)}) ] spids: [1132 1133 1152 -1] ) (case_arm pat_list: [{(h)}] action: [(C {(usage)}) (C {(exit)} {(0)})] spids: [1155 1156 1167 -1] ) (case_arm pat_list: [{(v)}] action: [ (C {(echo)} {(DQ ("Version ") ($ VSub_Name "$currentVersion"))}) (C {(exit)} {(0)}) ] spids: [1170 1171 1187 -1] ) (case_arm pat_list: [{(u)}] action: [(C {(update)}) (C {(exit)} {(0)})] spids: [1190 1191 1202 -1] ) (case_arm pat_list: [{(Lit_Other ":")}] action: [ (SimpleCommand words: [ {(echo)} {(DQ ("Option -") ($ VSub_Name "$OPTARG") (" requires an argument."))} ] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[1217])] ) (C {(exit)} {(1)}) ] spids: [1205 1206 1226 -1] ) ] spids: [1125 1129 1229] ) ] spids: [1122 1231] ) ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Pound "$#")} right: {(DQ (0))} ) ) terminator: <Op_Semi ";"> ) ] action: [(C {(getIPWeather)})] spids: [-1 1249] ) (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Number "$1")} right: {(DQ (help))} ) ) terminator: <Op_Semi ";"> ) ] action: [(C {(usage)})] spids: [1254 1268] ) (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Number "$1")} right: {(DQ (update))} ) ) terminator: <Op_Semi ";"> ) ] action: [(C {(update)})] spids: [1273 1288] ) (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Number "$1")} right: {(DQ (m))} ) ) terminator: <Op_Semi ";"> ) ] action: [(C {(getIPWeather)} {(DQ ("?m"))})] spids: [1293 1308] ) (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Number "$1")} right: {(DQ (i))} ) ) terminator: <Op_Semi ";"> ) ] action: [(C {(getIPWeather)} {(DQ ("?u"))})] spids: [1317 1332] ) ] else_action: [(C {(getLocationWeather)} {(DQ ($ VSub_At "$@"))})] spids: [1341 1350] ) ] )