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

Avoid calling abort in commands #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
17 changes: 13 additions & 4 deletions Commands/Move to Parent Listfile.tmCommand
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,37 @@
<string>nop</string>
<key>command</key>
<string>#!/usr/bin/env ruby18
require ENV['TM_SUPPORT_PATH'] + '/lib/exit_codes'
require ENV['TM_SUPPORT_PATH'] + '/lib/textmate'

abort "Unsaved file" unless ENV['TM_FILEPATH']
TextMate::exit_show_tool_tip("Unsaved file") unless ENV['TM_FILEPATH']

path = File.dirname(File.dirname(ENV['TM_FILEPATH'])) + "/CMakeLists.txt"
abort "No parent listfile" unless File.exist?(path)
TextMate::exit_show_tool_tip("No parent listfile") unless File.exist?(path)
TextMate.go_to(:file =&gt; path)

</string>
<key>fallbackInput</key>
<string>line</string>
<key>input</key>
<string>none</string>
<key>inputFormat</key>
<string>text</string>
<key>keyEquivalent</key>
<string>~@</string>
<key>name</key>
<string>Move to Parent Listfile</string>
<key>output</key>
<string>showAsTooltip</string>
<key>outputCaret</key>
<string>afterOutput</string>
<key>outputFormat</key>
<string>text</string>
<key>outputLocation</key>
<string>toolTip</string>
<key>scope</key>
<string>source.cmake</string>
<key>uuid</key>
<string>48A1D967-E8CF-4C16-A58F-60471E9469E3</string>
<key>version</key>
<integer>2</integer>
</dict>
</plist>
21 changes: 15 additions & 6 deletions Commands/Move to Subdirectory Listfile.tmCommand
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
<string>nop</string>
<key>command</key>
<string>#!/usr/bin/env ruby18
require ENV['TM_SUPPORT_PATH'] + '/lib/exit_codes'
require ENV['TM_SUPPORT_PATH'] + '/lib/textmate'
require ENV['TM_SUPPORT_PATH'] + '/lib/ui'

abort "Unsaved file" unless ENV['TM_FILEPATH']
TextMate::exit_show_tool_tip("Unsaved file") unless ENV['TM_FILEPATH']

line = STDIN.read
dir = File.dirname(ENV['TM_FILEPATH'])
Expand All @@ -19,32 +20,40 @@ if line =~ /ADD_SUBDIRECTORY\s*\((.+?)\)/i
subdir = $1
else
subdirs = Dir[dir + "/*/CMakeLists.txt"].map { |p| File.basename(File.dirname(p)) }.sort
abort "No listfile found in subdirectories" if subdirs.empty?
TextMate::exit_show_tool_tip("No listfile found in subdirectories") if subdirs.empty?
choice = TextMate::UI.menu(subdirs)
abort "Cancelled" unless choice
TextMate::exit_discard unless choice
subdir = subdirs[choice]
end

if subdir
file = subdir + "/CMakeLists.txt"
path = File.join(dir, file)
abort "The file at #{file} doesn't exist" unless File.exist?(path)
TextMate::exit_show_tool_tip("The file at #{file} doesn't exist") unless File.exist?(path)
TextMate.go_to(:file =&gt; path)
end
</string>
<key>fallbackInput</key>
<string>line</string>
<key>input</key>
<string>selection</string>
<key>inputFormat</key>
<string>text</string>
<key>keyEquivalent</key>
<string>~@</string>
<key>name</key>
<string>Move to Subdirectory Listfile</string>
<key>output</key>
<string>showAsTooltip</string>
<key>outputCaret</key>
<string>afterOutput</string>
<key>outputFormat</key>
<string>text</string>
<key>outputLocation</key>
<string>toolTip</string>
<key>scope</key>
<string>source.cmake</string>
<key>uuid</key>
<string>6F326FB4-8DC0-49BE-B74C-7B49CFA5283F</string>
<key>version</key>
<integer>2</integer>
</dict>
</plist>