Skip to content

Instantly share code, notes, and snippets.

@chrisgward
Last active August 29, 2015 13:56
Show Gist options
  • Save chrisgward/8999957 to your computer and use it in GitHub Desktop.
Save chrisgward/8999957 to your computer and use it in GitHub Desktop.
proc essentials_repo {n c t} {
set args [split $t " "]
set length [llength $args]
if {$length == 0} {
return [essentials_repo_usage]
} elseif {$length == 1} {
set type "Release"
} else {
switch -regexp -nocase -- [lindex $args 1] {
^d(ev(elopment)?)?(b(uild)?)?$ {
set type "Development"
}
^p(re(release)?)?(b(uild)?)?$ {
set type "Prerelease"
}
^r((el(ease)?)|(ec(ommend(ed)?)?)?)?(b(uild)?)?$ {
set type "Release"
}
default {
return [essentials_repo_usage]
}
}
}
switch -regexp -nocase -- [lindex $args 0] {
^(e(ss(entials)?)?)?((e(ss(entials)?)?)?|c(ore))$ {
set module "Essentials"
}
^(e(ss(entials)?)?)?a(nti)?(b(uild)?)?$ {
set module "EssentialsAntiBuild"
}
^(e(ss(entials)?)?)?c(hat)?$ {
set module "EssentialsChat"
}
^(e(ss(entials)?)?)?g(eo)?(i(p)?)?$ {
set module "EssentialsGeoIP"
}
^e(ss(entials)?)?g(roup)?m(an(ager)?)?$ {
set module "EssentialsGroupManager"
}
^g(roup)?m(an(ager)?)?$ {
set module "EssentialsGroupManager"
#TODO
}
^(e(ss(entials)?)?)?p(rot(ect)?)?$ {
set module "EssentialsProtect"
}
^(e(ss(entials)?)?)?s(pawn)?$ {
set module "EssentialsSpawn"
}
^(e(ss(entials)?)?)?x(mpp)?$ {
set module "EssentialsXMPP"
}
default {
return "Unrecognized module."
}
}
set document [dom::parse [wget "http://repo.chrisgward.com/content/groups/essentials/net/ess3/$module/maven-metadata.xml"]]
set versions [dom::selectNode $document "/metadata/versioning/versions/version"]
set build ""
for {set i [expr [llength $versions] - 1]} {$i >= 0} {incr i -1} {
set versionname [dom::node stringValue [lindex $versions $i]]
switch -regexp -- $versionname {
^[^D].+SNAPSHOT$ {
if {$type == "Development"} {
set build $versionname
break;
}
}
^Pre {
if {$type == "Prerelease"} {
set build $versionname
break;
}
}
^[\d\.]+$ {
if {$type == "Release"} {
set build $versionname
break;
}
}
}
}
dom::destroy $document;
if {$build == ""} {
return "No builds found for that version."
}
if {$type == "Development"} {
set document [dom::parse [wget "http://repo.chrisgward.com/content/groups/essentials/net/ess3/$module/$build/maven-metadata.xml"]]
set snapver [dom::selectNode $document {/metadata/versioning/snapshotVersions/snapshotVersion[1]/value}]
set url "http://repo.ess3.net/content/groups/essentials/net/ess3/$module/$build/$module-[dom::node stringValue $snapver].jar"
dom::destroy $document
} else {
set url "http://repo.ess3.net/content/groups/essentials/net/ess3/$module/$build/$module-$build.jar"
}
return "Latest $module $type build: $url"
}
proc essentials_repo_usage {} {
return {Usage: ^repo <module> [d|p|r]}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment