/usr/pkg/bin/pod2html: bin/gffmodify.pl: unexpected =item directive in paragraph 124. ignoring. gffmodify - Find matching items and modify them from the gff structures

NAME

gffmodify - Find matching items and modify them from the gff structures


SYNOPSIS

gffmodify [--help|-h] [--version|-V] [--verbose|-v] [--config config-file] [--no-write|-n] [--interactive|-i] [--backup|-b] [--find-struct|-s structure-regexp] [--print-fields|-p fields-to-print-regexp] --find|-f label-regexp:=:value-regexp [--find|-f label-regexp:=:value-regexp ...] [--find|-f label-regexp:!:value-regexp ...] [--or|-o --find|-f label-regexp:=:value-regexp ...] [--modify|-m label=value] [--modify|-m label[#type]=value|@ask[(default)]@] [--variable varname=value] [--variable varname[#int|float|string]=value] [--parameter|-P name=relative-path] [--global-parameter|-g name=absolute-path] [--area-parameter|-a name=absolute-path] [--variable-parameter name=varname] [--variable-parameter name=/globalvarname] [--variable-parameter name=..parentvarname] filename ...

gffmodify --help


DESCRIPTION

gffmodify first finds the structure specified with the -s option (or use root if it is not set). Then it starts matching the list of -f options in the order of all of them match then it will start modifying the structure. All -f options are anded together, and multiple set of -f options can be given separated with -o which are then ored together (i.e. if any of the sets ored together matches then modify structure).

When the matching structure is found, then the modifications listed in the --modify are done in the order they are given. There can be multiple --modify options. If the value is @ask@ then the program will ask for new value for the field. If you want to use some other default than the old value, simply use @ask(default)@ as a new value.

In addition to changing the value of fields, the gffmodify can add variables to the given structure. This can be done by using --variable option. The --variable option works just like --modify but it will add variable instead of modifying field.

When using interactive options (-i to prompt before, or @ask@) then the -p option might be useful to print out some field from the struct.

If information needs to be copied from different parts of the tree to some other parts, then named parameters can be used to do that. Named parameters are created by using --parameter, --global-parameter, --area-parameter or --variable-parameter. Each of those options takes a name of the parameter and the path to use when getting the parameter value. The --parameter takes the parameters from the given structure, i.e. the path is relative to the current matched structure. The --global-parameter takes the parameters from the toplevel structure, and --area-parameter takes them from the area file instead of this git file (it is useful when getting for example Name or Tag of the area). As area name and tag are so commonly used there is always automatic paramters @areaname@ and @areatag@ which are set to match the area name and tag.

The --variable-parameter takes the parameter value from the variables. It can take 3 different types of input. If the varname is simply normal variable then it is taken from the current structure. If it is /varname then it is taken from the toplevel structure, and if it is ..varname then it is is taken from the matching structure, and if not set there then from the parent structure etc.

When adding new items the type normally needs to be given. Types are given in numbers just like the __type field has (0 = byte, 1 = char, 2 = word, etc). If you are modifying old value, then no need to set type. You cannot add items to arrays using this tool yet, you can only add or modify fields in the structures.


OPTIONS

--help -h
Prints out the usage information.

--version -V
Prints out the version information.

--verbose -v
Enables the verbose prints. This option can be given multiple times, and each time it enables more verbose prints.

--config config-file
All options given by the command line can also be given in the configuration file. This option is used to read another configuration file in addition to the default configuration file.

--no-write -n
Do not write anything, but do the modifications etc. This can be used to check that everything is modified properly before actually doing the modification.

--interactive -i
Ask for verification before doing the actual change.

--backup -b
Take backup copy of the file before writing it back. The backup copy will be named file.git.bak.

--find-structure -s structure-regexp
The given regexp is used to match against all full paths inside the structure when it is processed, and if the regexp match, then this structure is given to the actual matcher. This should specify the structure where you want to do the matching using -f options. It should be something like ^/Creature List\\[\\d+\\]/\$.

--print-fields -p fields-to-print-regexp
When the matching structure has been found, then print out fields matching this regexp. This regexp gets the full path to the object, but you can only print items which are inside the matched structure. You cannot print values from the substructure of the selected one. If this list contains @name@ it is replaced with the named paramter name. For areas there is automatic parameters named @areaname@, and @areatag@. For all items there is always the @path@. Those items can appear anywhere on the regexp and if they are there, the values of them are printed out. So use them inside the regexp like this: Name|Tag|@areaname@.

--find -f label-regexp:=:value-regexp>
Match the value from field matching the given label-regexp (full path) to the value-regexp. If the values match then print out information. If there is multiple -f options they are anded together, or if they are separated with -o then the two (or more) sets of find options are ored together.

--find -f label-regexp:!:value-regexp>
Match the value from field matching the given label-regexp (full path) to the value-regexp. If the values do not match then print out information. If there is multiple -f options they are anded together, or if they are separated with -o then the two (or more) sets of find options are ored together.

--or -o
Used to or two (or more) sets of find options together. I.e. if any of them match then print out information.

--modify -m label[#type]=value
Do the actual modification. Modify the label (relative to the current matched structure, but it can contain path), and set it to have value. If this is new value then type needs to be given. The value can also be special value @ask@ in which case the value will be asked from user. The default for the @ask@ can be given in parenthesis after the ask text, i.e. @ask(default)@. The value can also contain any of the named parameters, and those named parameters can even be used as a default value (i.e. @ask(@areaname@)@.

--variable varname[#int|float|string]=value]
Add, change or remove variable of the current structure. Modify the varname, and set it to have value. If this is new value then type is only needed in case it cannot be guessed properly from the value (i.e. if value is only numbers then the type defaults to int, if it floating point number then it defaults to float, and otherwise it defaults to string). If you want to remove variable simply set its value to @remove@.

The value can also be special value @ask@ in which case the value will be asked from user. The default for the @ask@ can be given in parenthesis after the ask text, i.e. @ask(default)@. The value can also contain any of the named parameters, and those named parameters can even be used as a default value (i.e. @ask(@areaname@)@.

--parameter -P name=relative-path
Define named parameter name to have value taken from reading the value from the item specified by the relative-path. The relative-path is relative to the current matched structure. This name can then be used in the -p structure in format @name@. It can also be used when modifying field or setting variables. It cannot be used when matching the structure.

--global-parameter -g name=absolute-path
Define named parameter name to have value taken from reading the value from the item specified by the absolute-path. The absolute-path is relative to the top structure. This name can then be used in the -p structure in format @name@. It can also be used when modifying field or setting variables. It cannot be used when matching the structure.

--area-parameter -a name=absolute-path
Define named parameter name to have value taken from reading the value from the item specified by the absolute-path. The absolute-path is relative to the top structure of the matching area file (.are). This name can then be used in the -p structure in format @name@. It can also be used when modifying field or setting variables. It cannot be used when matching the structure.

--variable-parameter name=varname
Define named parameter name to have value taken from reading the value from the variable specified by the varname. If the varname starts withe / then then variable read from the top structure. If it starts with .. then the variable is read first from mathing structure, and if not found there, the parent structure, etc until it is read from the top structure. In other cases the variable is read directly from the matching structure.

This name can then be used in the -p structure in format @name@. It can also be used when modifying field or setting variables. It cannot be used when matching the structure.

    =head1 EXPRESSIONS

The named parameter can also do simple expressions. I.e. instead of only @name@ they can have @random(12)@ or similar functions which are replaced with the output of the given function.

Supported functions are:

@random@ | @random(number)@
Generates random number from 1 to number (number included). The default of 1000000 is used as max if no number is given.

@random0(number)@
Generates random number from 0 to number (number excluded).

@frandom(number)@
Generates floating point random number from 1 to number (up to number + 1 - epsilon).

@frandom0(number)@
Generates floating point random number from 0 to number (up to number - epsilon).

@counter@ | @counter(number)@ | @counter(number, mod)@
Generates counter that is incremented every time it is used. If number is given then start from that value, otherwise start from zero. If mod is given then return numbers from number to number + mod - 1.

@substr(str, start)@ | @substr(str, start, len)@
Takes a substring of the str starting from offset start and with length of len. offset starts from 0, and if offset is negative then it is calculated from the end of the string. If len is omitted then it assumed to be rest of the string, and if it is negative, then it will remove that many characters from the end of string.


EXAMPLES

    gffmodify.pl \
        -v \
        -s '^/$' \
        -f '^/ScriptOnNotice$:=:^X$' \
        -m '/ScriptOnNotice=Y' \
        -m '/ScriptSpawn=Z' \
        *.utc
    gffmodify.pl \
        -v \
        -s '^/Placeable List\[\d+\]/$' \
        -f '/OnOpen$:=:^X$' \
        -m '/OnOpen=Y' \
        *.git
    gffmodify.pl -v -f '/Tag$:=:^CELIALIAMYN$' -m 'Tag=CELIASAD' Celia.utc
    gffmodify.pl \
        -p 'Fog|Tag|@areaname@' \
        -f '^/FogClipDist$:=:.' \
        -m 'FogClipDist=@ask(55)@' \
        -v \
        *.are 
    gffmodify.pl \
        -p 'Plot|Static|Useable|LocName|Tag|@areaname@' \
        -s '^/Placeable List\[\d+\]/$' \
        -f '/Plot$:=:^0$' \
        -m 'Plot=@ask@' \
        -v *.git
    gffmodify.pl \
        -v \
        -s '^/Door List\[\d+\]/$' \
        -f '/Locked$:=:^0$' \
        -f '/Lockable$:=:^0$' \
        -f '/KeyRequired$:=:^0$' \
        -f '/KeyName$:=:^$' \
        -m '/KeyRequired=1' \
        -m 'KeyName=dm_quest_key' \
        *.git
    gffmodify.pl \
        -p '@areaname@|@areatag@|/Var' \
        --variable 'X2_L_WILD_MAGIC=1' \
        -v \
        *.git
    gffmodify.pl \
        -p 'FirstName|@areaname@|@areatag@|@wild@|@height@|@item@|@tag@' \
        -P 'tag=Tag' \
        -variable-parameter 'wild=/X2_L_WILD_MAGIC' \
        -a 'width=/Width' \
        -a 'height=/Height' \
        -s '^/Creature List\[\d*\]/$' \
        --variable-parameter 'item=giveitem1' \
        -f '/ChallengeRating$:=:.' \
        -m 'ClassList[0]/ClassLevel=@ask(@height@)@' -v foo.git


FILES

~/.gffmodifyrc
Default configuration file.


SEE ALSO

gffencode(1), gffmatch(1), gffprint(1), Gff(3), and GffRead(3).


AUTHOR

Tero Kivinen <kivinen@iki.fi>.


HISTORY

This program evolved from gffmatch(1) and has been enchanced after that to support variables and parameters etc.