# # $Id: grep.pretty,v 1.2 1998/08/06 18:50:33 joi Exp joi $ # $Log: grep.pretty,v $ # Revision 1.2 1998/08/06 18:50:33 joi # Added more sanity checking. # # Revision 1.1 1998/08/06 18:37:50 joi # Initial revision # # # #include /home/joi/MyMush/dbrefs.inc # # /quote -wjoi -1 !"unprettify -v <~/MyMush/grep.pretty" # # This file creates a global command "+grep". To avoid complications # from local server settings dealing with far_seeing, determining the # object of interest, etc, this command should be placed on a wizard # object or wizard-own inherit object in your master room. # # This command allows mortals to grep objects for string matches. # This version allows visual objects owned by anyone to be grepped. # If you do not want this, remove the ",hasflag(%q9,VISUAL)" from # the switch evaluation. # # The latest version of this file may be found at: # http://www.visi.com/~gyles19/mushcode/grep.pretty # http://www.visi.com/~gyles19/mushcode/grep.mush # # Instructions: # # This file assumes the following objects already exist: # WIZZED OBJECT : object in your master room with wizard powers # WIZZED OBJECT PARENT : object that holds non-command attributes. This # can be your wizzed object itself, if necessary. # HELP OBEJCT : the object where your +help system stores its topics. # # If these objects don't already exist, your GOD will need to preform the # following commands: # # @create WIZZED OBJECT # @set WIZZED OBJECT=WIZARD # @create WIZZED OBJECT PARENT # @parent WIZZED OBJECT=WIZZED OBJECT PARENT # @teleport wizzed object=[master room] # # Once the objects are created, place attributes on yourself as follows: # # &DBREF_WIZZED_OBJECT me=[dbref of your wizard object] # &DBREF_WIZZED_OBJECT_PARENT me=[dbref of your wizard object's parent] # &DBREF_HELP_OBJECT me=[dbref of your help text object] # # These attributes are only used during the quoting process and may be # removed when the installation is complete. # # Finally, unprettify this file and quote it into your mush. # # This can be done with TinyFugue in one step: # /quote -w -1 !"unprettify -v grep.mush # and quote the "grep.mush" file into your mush using whatever method # suits you. # # Alternatively, you can download grep.mush from my website and quote # that directly. # # The supplied +help topic is compatible with my +help command. # - &FILTER_GREP [v(DBREF_WIZZED_OBJECT_PARENT)]= strmatch(get(%q9/%0),*%q8*) - &DO_GREP [v(DBREF_WIZZED_OBJECT)]=$+gre* *=*: @switch/first setq(9,locate(%#,secure(%1),*V)) [setq(5,secure(%0))] [setq(8,secure(%2))] %q9+[or(match(%#,owner(%q9)),hasflag(%q9,VISUAL),hasflag(%#,WIZARD))]= #-2*, { @pemit %#=I don't know which one you mean! }, #-1*, { @pemit %#=I don't see that here. }, *+1, { @pemit %#= [setq(7,lattr(%q9))] [setq(6, setunion( filter(filter_grep,%q7), [switch(%q5,p/*name*,lattr(%q9/*%q8*))] ) )] Attributes on [name(%q9)](%q9) that[switch(%q5,*name*,%bmatch and)] contain "%q8": [switch( words(%q6), 0,%rNo Matches found., [iter( %q6, %r##[switch(%q5,p/*list*,%r%t[get(%q9/##)])] )] )]; @pemit %#= [switch( parent(%q9), #-1, , [name(%q9)](%q9) is parented to [name(parent(%q9))]([parent(%q9)]). )] }, { @pemit %#=Permission denied. } - # # /quote -wjoi -0 !"unprettify -v HELP_grep <~/MyMush/grep.pretty" # &HELP_grep [v(dbref_help_object)]= ######################################################################## "The syntax of the command is: " +grep object=string " "Optional Switches: " /name Matches against the attribute name as well as the contents. " /list Lists the contents of matching attributes " "This command searches an object for attributes that contain the "specified string, which may contain wild cards. By default, only "attribute namess whose contents contain the string are listed. " "The /list switch will display the contents of the attributes. "The /name switch will include the name of the attribute in the test. "The /list and /name switches may be combined. " "You may only +grep objects which you own, or which are set VISUAL. "Wizards may +grep anything. -