Ticket #49009: port-edit-state

File port-edit-state, 871 bytes (added by RJVB (René Bertin), 9 years ago)

Allows to edit the state files of the given port(s) in YFE

Line 
1#!/bin/sh
2
3PORT=""
4OPTS=""
5
6while [ $# != 0 ] ;do
7        case $1 in
8                --editor)
9                        shift
10                        EDITOR="$1"
11                        if [ "${EDITOR}" = "native" ] ;then
12                                EDITOR="open -t"
13                        fi
14                        ;;
15                -*)
16                        OPTS="${OPTS} $1"
17                        ;;
18                *)
19                        PORT="${PORT} $1"
20                        ;;
21        esac
22        shift
23done
24
25if [ "${EDITOR}" != "" -a "${PORT}" != "" ] ;then
26        for p in $PORT ;do
27                WD="`port work ${p}`"
28                if [ -d ${WD} ] ;then
29                        #echo ${EDITOR} ${OPTS} ${WD}/.macports.${p}.state
30                        ${EDITOR} ${OPTS} ${WD}/.macports.${p}.state
31                fi
32        done
33else
34        echo "Usage: `basename $0` [--editor app] [-options] <port1> [port2 [port3 [...]]]"
35        echo "This utility allows you to edit the statefile from a port's work directory"
36        echo "Use --editor native to invoke the default native text editor"
37        echo "Remember to quote spaces in the editor app name or in options that take an argument"
38        echo "  (e.g. `basename $0` \"-t tabsize\") foo"
39fi