I'm trying to add a Delete command to the Subversion bundle. I've got the basics working, but now I'm trying to make it look nice.
Here's the command as it is now:
require_cmd "${TM_SVN:=svn}" "If you have installed svn, then you need to either update your <tt>PATH</tt> or set the <tt>TM_SVN</tt> shell variable (e.g. in Preferences / Advanced)"
rv=`CocoaDialog textbox --title "Delete from Repository" --string- output --no-newline \ --informative-text "These files will be scheduled for deletion during the next commit." \ --text "${TM_SELECTED_FILES:-$TM_FILEPATH}" --button1 "Delete" -- button2 "Cancel"`
if [ "$rv" == "Delete" ]; then eval "$TM_SVN" del "${TM_SELECTED_FILES:-$TM_FILEPATH}" elif [ "$rv" == "No" ]; then exit elif [ "$rv" == "Cancel" ]; then exit fi
What I want is the list of files in the CocoaDialog textbox to be newline-separated, and have the enclosing quotes removed (ideally, the project base path as well). I don't have any bash-fu to figure this out.
Help please?
Thanks, Ken Scott
On 3/4/2006, at 1:24, Ken Scott wrote:
if [ "$rv" == "Delete" ]; then eval "$TM_SVN" del "${TM_SELECTED_FILES:-$TM_FILEPATH}"
You should split the last line up into:
if [[ -n "$TM_SELECTED_FILES" ]]; then eval "$TM_SVN" del "$TM_SELECTED_FILES" else "$TM_SVN" del "$TM_FILEPATH" fi
Because only with TM_SELECTED_FILES do we want to re-evaluate the line, after initial variable expansion.
elif [ "$rv" == "No" ]; then exit elif [ "$rv" == "Cancel" ]; then exit fi
You can do:
elif [[ "$rv" == "No" || "$rv" == "Cancel" ]]; then exit fi
What I want is the list of files in the CocoaDialog textbox to be newline-separated, and have the enclosing quotes removed (ideally, the project base path as well). I don't have any bash-fu to figure this out.
Here you go. First it converts the variable to a bash array, then it iterates over the array, writes the filename with a potential $TM_PROJECT_DIRECTORY/ prefix removed.
The CocoaDialog code calls this function and sorts the result (to get a sorted file listing).
file_list () { if [[ -n "$TM_SELECTED_FILES" ]]; then eval arr=("$TM_SELECTED_FILES") for (( i = 0; i < ${#arr[@]}; i++ )); do FILE="${arr[$i]}" echo "${FILE##$TM_PROJECT_DIRECTORY/}" done else echo "$TM_FILENAME" fi }
rv=`CocoaDialog textbox --title "Delete from Repository" \ --string-output --no-newline --informative-text \ "These files will be scheduled for deletion during the next commit." \ --text "$(file_list|sort -f)" --button1 "Delete" --button2 "Cancel"`
Thank you Allan, I appreciate the help. It appears to work perfectly.
I would like to submit the following command to the Subversion bundle
Thanks, Ken Scott
On Apr 2, 2006, at 5:53 PM, Allan Odgaard wrote:
On 3/4/2006, at 1:24, Ken Scott wrote:
if [ "$rv" == "Delete" ]; then eval "$TM_SVN" del "${TM_SELECTED_FILES:-$TM_FILEPATH}"
You should split the last line up into:
if [[ -n "$TM_SELECTED_FILES" ]]; then eval "$TM_SVN" del "$TM_SELECTED_FILES" else "$TM_SVN" del "$TM_FILEPATH" fi
Because only with TM_SELECTED_FILES do we want to re-evaluate the line, after initial variable expansion.
elif [ "$rv" == "No" ]; then exit elif [ "$rv" == "Cancel" ]; then exit fi
You can do:
elif [[ "$rv" == "No" || "$rv" == "Cancel" ]]; then exit fi
What I want is the list of files in the CocoaDialog textbox to be newline-separated, and have the enclosing quotes removed (ideally, the project base path as well). I don't have any bash-fu to figure this out.
Here you go. First it converts the variable to a bash array, then it iterates over the array, writes the filename with a potential $TM_PROJECT_DIRECTORY/ prefix removed.
The CocoaDialog code calls this function and sorts the result (to get a sorted file listing).
file_list () { if [[ -n "$TM_SELECTED_FILES" ]]; then eval arr=("$TM_SELECTED_FILES") for (( i = 0; i < ${#arr[@]}; i++ )); do FILE="${arr[$i]}" echo "${FILE##$TM_PROJECT_DIRECTORY/}" done else echo "$TM_FILENAME" fi }
rv=`CocoaDialog textbox --title "Delete from Repository" \ --string-output --no-newline --informative-text \ "These files will be scheduled for deletion during the next commit." \ --text "$(file_list|sort -f)" --button1 "Delete" --button2 "Cancel"`
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate