Skip to content
Permalink
Browse files

Add new actions to port(1):

	- path (emits the path to the port's directory)
	- portfile (emits the path to the portfile)
	- cat (copies the portfile to standard output)
	- ed (invokes any editor specified in EDITOR or VISUAL on the portfile)

Based on a feature request by Juan.

git-svn-id: https://svn.macports.org/repository/macports/trunk/base@14506 d073be05-634f-4543-b044-5fe20cf6d1d6
  • Loading branch information
jdberry committed Oct 9, 2005
1 parent d0c3aba commit 83b7fc82d670cecb03896f2fb380396d20c90716
Showing with 78 additions and 2 deletions.
  1. +3 −1 ChangeLog
  2. +75 −1 src/port/port.tcl
@@ -1,5 +1,5 @@
#
# $Id: ChangeLog,v 1.6 2005/10/09 13:54:26 jberry Exp $
# $Id: ChangeLog,v 1.7 2005/10/09 15:31:27 jberry Exp $
#
# This is a log of major user-visible changes in each release
#
@@ -84,6 +84,8 @@ Release 1.2:
that have taken place since 1.1 ("bunch of developers ;-);

- Snazzy new ChangeLog file

- Add new actions for port(1): help, echo, cat, ed, path, portfile (jberry)


Release 1.1:
@@ -2,7 +2,7 @@
#\
exec @TCLSH@ "$0" "$@"
# port.tcl
# $Id: port.tcl,v 1.113 2005/10/08 22:24:14 jberry Exp $
# $Id: port.tcl,v 1.114 2005/10/09 15:31:28 jberry Exp $
#
# Copyright (c) 2004 Robert Shaw <rshaw@opendarwin.org>
# Copyright (c) 2002 Apple Computer, Inc.
@@ -49,6 +49,10 @@ array set ui_options {}
array set global_options {}
array set global_variations {}

# Save off a copy of the environment before dportinit monkeys with it
global env
array set boot_env [array get env]

# UI Instantiations
# ui_options(ports_debug) - If set, output debugging messages.
# ui_options(ports_verbose) - If set, output info messages (ui_info)
@@ -127,6 +131,7 @@ proc ui_channels {priority} {
}
}


# Standard procedures
proc print_usage args {
global argv0
@@ -1693,6 +1698,75 @@ switch -- $action {
}
}

ed -
cat -
path -
portfile {
# Operations on the PortFiles of the port
require_portlist
foreachport $portlist {
# If we have a url, use that, since it's most specific
# otherwise try to map the portname to a url
if {$porturl == ""} {
# Verify the portname, getting portinfo to map to a porturl
if {[catch {set res [dportsearch $portname no exact]} result]} {
global errorInfo
ui_debug "$errorInfo"
fatal_softcontinue "search for portname $portname failed: $result"
}
if {[llength $res] < 2} {
fatal_softcontinue "Port $portname not found"
}
array set portinfo [lindex $res 1]
set porturl $portinfo(porturl)
}

set portdir [darwinports::getportdir $porturl $portdir]
set portfile "${portdir}/PortFile"

if {[file readable $portfile]} {
switch -- $action {
cat {
# Copy the portfile to standard output
set f [open $portfile RDONLY]
while { ![eof $f] } {
puts [read $f 4096]
}
close $f
}

ed {
# Find an editor to edit the portfile
set editor ""
foreach ed { VISUAL EDITOR } {
if {[info exists boot_env($ed)]} {
set editor $boot_env($ed)
}
}

if { $editor == "" } {
fatal "No EDITOR is specified in your environment"
} else {
eval exec $editor $portfile
}
}

path {
# output the path to the port
puts $portdir
}

portfile {
# output the path to the portfile
puts $portfile
}
}
} else {
fatal_softcontinue "Could not read $portfile"
}
}
}

sync {
if {[catch {dportsync} result]} {
global errorInfo

0 comments on commit 83b7fc8

Please sign in to comment.
You can’t perform that action at this time.