Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add vercmp as a port action that compares two versions #229

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/port/port.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -4230,6 +4230,26 @@ proc action_mirror { action portlist opts } {
action_target $action $portlist $opts
}

proc action_vercmp { action portlist opts } {
if {[llength $portlist] != 2} {
ui_error "Usage: port vercmp versionA versionB"
return 1
}
set versionA [lindex $portlist 0]
set versionB [lindex $portlist 1]
set result [vercmp $versionA $versionB]
ui_msg -nonewline "MacPorts considers $versionA to be "
if {$result < 0} {
ui_msg -nonewline "less than"
} elseif {$result == 0} {
ui_msg -nonewline "equal to"
} else {
ui_msg -nonewline "greater than"
}
ui_msg " $versionB"
return 0
}

proc action_exit { action portlist opts } {
# Return a semaphore telling the main loop to quit
return -999
Expand Down Expand Up @@ -4368,6 +4388,8 @@ array set action_array [list \
mpkg [list action_target [ACTION_ARGS_PORTS]] \
pkg [list action_target [ACTION_ARGS_PORTS]] \
\
vercmp [list action_vercmp [ACTION_ARGS_STRINGS]] \
\
quit [list action_exit [ACTION_ARGS_NONE]] \
exit [list action_exit [ACTION_ARGS_NONE]] \
]
Expand Down