Bellhop Help

Adding Services

To add services to the database, use the File > New Service menu item (Cmd-N) or select New Service from the service list action menu. This will bring up a sheet where you can give your new service a name, set its language and assign it to a collection.


New service sheet

Pressing the Create button will initialize a new service and add it to the collection that was selected in the sheet. You can change the label of the newly created service by double-clicking it in the list, or using the service settings drawer (see the section on Configuring Services).

The new service will contain boilerplate code that is tailored for the language that was selected when creating the new service. For example, all new Ruby services all have the following code:

# aPasteboard identifies the unique pasteboard name reserved for
# the service transaction. Use this name as the argument to the 
# various methods that get and set data from the pasteboard.
#

def runService (aPasteboard)

    # Add your custom Ruby code here...
    #

end

# The following globals are available for functions that 
# require a pasteboard type as an argument:
#
# NSStringPboardType  NSTabularTextPboardType  NSFilenamesPboardType,
# NSRTFPboardType     NSPostScriptPboardType   NSFileContentsPboardType,
# NSHTMLPboardType    NSPDFPboardType          NSRTFDPboardType
# NSTIFFPboardType    NSPICTPboardType         NSURLPboardType
# NSColorPboardType   NSRulerPboardType        NSFontPboardType
#
# To access the general pasteboard (i.e. the clipboard), use the 
# NSGeneralPboard global variable as the pasteboard name in any of the
# pasteboard module methods.

Code for new Ruby services


There is additional help for each language plug-in (also known as a context) that Bellhop supports. For example, for more details on writing a Ruby service using Bellhop, you can select Help > Ruby Context Help, which will open up a separate help window detailing the Ruby language plug-in. There are similar help files for each of the supported language plugins (AppleScript, F-Script, Perl, Python and Ruby).

After you've edited your service's script code, you can then configure your service using the inspector.