proc current_version { var plugin_name = $1 check_if_plugin_exists $plugin_name var search_path = '' search_path := $[pwd] var version_and_path = '' version_and_path := $[find_version $plugin_name $search_path] var version = '' version := $[cut -d '|' -f 1 <<< $version_and_path]; check_if_version_exists $plugin_name $version check_for_deprecated_plugin $plugin_name if test -z $version { echo "No version set for $plugin_name" exit 1 } else { echo $version exit 0 } } proc which_command { var plugin_name = $1 var plugin_path = '' plugin_path := $[get_plugin_path $plugin_name] check_if_plugin_exists $plugin_name var install_type = '"version'" var install_path = '' install_path := $[get_install_path $plugin_name $install_type $[current_version $plugin_name]] if test -d $install_path { echo "$install_path/bin/$plugin_name" exit 0 } else { echo "Version not installed" exit 1 } } # Warn if the plugin isn't using the updated legacy file api. proc check_for_deprecated_plugin { var plugin_name = $1 var plugin_path = '' plugin_path := $[get_plugin_path $plugin_name] var legacy_config = '' legacy_config := $[get_asdf_config_value "legacy_version_file] var deprecated_script = ""$(plugin_path)/bin/get-version-from-legacy-file"" var new_script = ""$(plugin_path)/bin/list-legacy-filenames"" if test $legacy_config = "yes" && test -f $deprecated_script && test ! -f $new_script { echo "Heads up! It looks like your $plugin_name plugin is out of date. You can update it with:" echo "" echo " asdf plugin-update $plugin_name" echo "" } } (CommandList children: [ (FuncDef name: current_version body: (BraceGroup children: [ (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:plugin_name) op: Equal rhs: {($ VSub_Number "$1")} spids: [9] ) ] spids: [7] ) (C {(check_if_plugin_exists)} {(DQ ($ VSub_Name "$plugin_name"))}) (Assignment keyword: Assign_Local pairs: [(assign_pair lhs:(LhsName name:search_path) op:Equal spids:[24])] spids: [22] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:search_path) op: Equal rhs: { (CommandSubPart command_list: (CommandList children:[(C {(pwd)})]) left_token: spids: [28 30] ) } spids: [27] ) ] spids: [27] ) (Assignment keyword: Assign_Local pairs: [(assign_pair lhs:(LhsName name:version_and_path) op:Equal spids:[35])] spids: [33] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:version_and_path) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (C {(find_version)} {(DQ ($ VSub_Name "$plugin_name"))} {(DQ ($ VSub_Name "$search_path"))} ) ] ) left_token: spids: [39 49] ) } spids: [38] ) ] spids: [38] ) (Assignment keyword: Assign_Local pairs: [(assign_pair lhs:(LhsName name:version) op:Equal spids:[54])] spids: [52] ) (Sentence child: (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:version) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (SimpleCommand words: [{(cut)} {(-d)} {(SQ <"|">)} {(-f)} {(1)}] redirects: [ (Redir op_id: Redir_TLess fd: -1 arg_word: {(DQ ($ VSub_Name "$version_and_path"))} spids: [71] ) ] ) ] ) left_token: spids: [58 76] ) } spids: [57] ) ] spids: [57] ) terminator: ) (C {(check_if_version_exists)} {(DQ ($ VSub_Name "$plugin_name"))} {(DQ ($ VSub_Name "$version"))} ) (C {(check_for_deprecated_plugin)} {(DQ ($ VSub_Name "$plugin_name"))}) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-z)} {(DQ ($ VSub_Name "$version"))} {(Lit_Other "]")}) terminator: ) ] action: [ (C {(echo)} {(DQ ("No version set for ") ($ VSub_Name "$plugin_name"))}) (C {(exit)} {(1)}) ] spids: [-1 113] ) ] else_action: [(C {(echo)} {(DQ ($ VSub_Name "$version"))}) (C {(exit)} {(0)})] spids: [129 144] ) ] spids: [4] ) spids: [0 3] ) (FuncDef name: which_command body: (BraceGroup children: [ (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:plugin_name) op: Equal rhs: {($ VSub_Number "$1")} spids: [158] ) ] spids: [156] ) (Assignment keyword: Assign_Local pairs: [(assign_pair lhs:(LhsName name:plugin_path) op:Equal spids:[164])] spids: [162] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:plugin_path) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [(C {(get_plugin_path)} {(DQ ($ VSub_Name "$plugin_name"))})] ) left_token: spids: [168 174] ) } spids: [167] ) ] spids: [167] ) (C {(check_if_plugin_exists)} {(DQ ($ VSub_Name "$plugin_name"))}) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:install_type) op: Equal rhs: {(DQ (version))} spids: [186] ) ] spids: [184] ) (Assignment keyword: Assign_Local pairs: [(assign_pair lhs:(LhsName name:install_path) op:Equal spids:[195])] spids: [193] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:install_path) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (C {(get_install_path)} {(DQ ($ VSub_Name "$plugin_name"))} {(DQ ($ VSub_Name "$install_type"))} { (DQ (CommandSubPart command_list: (CommandList children: [ (C {(current_version)} {(DQ ($ VSub_Name "$plugin_name"))}) ] ) left_token: spids: [211 217] ) ) } ) ] ) left_token: spids: [199 219] ) } spids: [198] ) ] spids: [198] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-d)} {(DQ ($ VSub_Name "$install_path"))} {(Lit_Other "]")} ) terminator: ) ] action: [ (C {(echo)} {(DQ ($ VSub_Name "$install_path") (/bin/) ($ VSub_Name "$plugin_name"))} ) (C {(exit)} {(0)}) ] spids: [-1 236] ) ] else_action: [(C {(echo)} {(DQ ("Version not installed"))}) (C {(exit)} {(1)})] spids: [253 268] ) ] spids: [153] ) spids: [149 152] ) (FuncDef name: check_for_deprecated_plugin body: (BraceGroup children: [ (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:plugin_name) op: Equal rhs: {($ VSub_Number "$1")} spids: [285] ) ] spids: [283] ) (Assignment keyword: Assign_Local pairs: [(assign_pair lhs:(LhsName name:plugin_path) op:Equal spids:[292])] spids: [290] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:plugin_path) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [(C {(get_plugin_path)} {(DQ ($ VSub_Name "$plugin_name"))})] ) left_token: spids: [296 302] ) } spids: [295] ) ] spids: [295] ) (Assignment keyword: Assign_Local pairs: [(assign_pair lhs:(LhsName name:legacy_config) op:Equal spids:[307])] spids: [305] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:legacy_config) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [(C {(get_asdf_config_value)} {(DQ (legacy_version_file))})] ) left_token: spids: [311 317] ) } spids: [310] ) ] spids: [310] ) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:deprecated_script) op: Equal rhs: {(DQ (${ VSub_Name plugin_path) (/bin/get-version-from-legacy-file))} spids: [322] ) ] spids: [320] ) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:new_script) op: Equal rhs: {(DQ (${ VSub_Name plugin_path) (/bin/list-legacy-filenames))} spids: [333] ) ] spids: [331] ) (If arms: [ (if_arm cond: [ (Sentence child: (AndOr children: [ (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$legacy_config"))} {(Lit_Other "=")} {(DQ (yes))} {(Lit_Other "]")} ) (AndOr children: [ (C {(Lit_Other "[")} {(-f)} {(DQ ($ VSub_Name "$deprecated_script"))} {(Lit_Other "]")} ) (C {(Lit_Other "[")} {(KW_Bang "!")} {(-f)} {(DQ ($ VSub_Name "$new_script"))} {(Lit_Other "]")} ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) terminator: ) ] action: [ (C {(echo)} { (DQ ("Heads up! It looks like your ") ($ VSub_Name "$plugin_name") (" plugin is out of date. You can update it with:") ) } ) (C {(echo)} {(DQ )}) (C {(echo)} {(DQ (" asdf plugin-update ") ($ VSub_Name "$plugin_name"))}) (C {(echo)} {(DQ )}) ] spids: [-1 386] ) ] spids: [-1 418] ) ] spids: [280] ) spids: [276 279] ) ] )