| Extracted from Pike v7.8 release 866 at 2018-07-18.

[Top]
Tools
Tools.Standalone
Tools.Standalone.process_files

# Class Tools.Standalone.process_files

Description

  Boilerplate to quickly whip up rsif-like hacks for creating file processing to churn away at stdin, or files and/or directories provided on the command line, recursively or not, creating backup files or not, listing the paths of all files action was taken for, and returning an exit status of how many files that would have been taken action on which could not be written back.

  The all-round quickest way of making one of these tools is nicking the top portion of `lib/modules/Tools.pmod/Standalone.pmod/process_files.pike` or copying `rsif.pike` from the same directory. (The latter is 20 lines long, including docs, or about four lines of code.) Inherit process_files, and define your own version , description , usage , process , and, if you want arguments, want_args .

Inherit process_files

  inherit Toole.Standalone.process_files : process_files

Variable version

  `string Tools.Standalone.process_files.version`

Description

  Your hack's version number. If you version control your file with cvs, we suggest you set the contents of this variable to something that that will automatically expand to a number for every new revision, for instance

Example

      string version =
          sprintf("%d.%d.%d",(int)__REAL_VERSION__,__REAL_MINOR__,__REAL_BUILD__);

Variable description

  `string Tools.Standalone.process_files.description`

Description

  One-liner that gets shown for this tool when running `pike -x` without additional options. (Assuming your tool resides in `Standalone.pmod`.) Does not include the name of the tool itself; just provide a nice, terse description, ending with a period for conformity.

Variable usage

  `string Tools.Standalone.process_files.usage`

Description

  Long description of the purpose and usage of your tool, for --help and the case where not enough options are given on the command line. Its invocation mode (for instance "pike -x yourtool", when invoked that way) is prepended, and a list of available flags appended to this description.

Variable want_args

  `int Tools.Standalone.process_files.want_args`

Description

  The number of (mandatory) command-line options your hack needs and which your process callback wants (beside the input file). By default 0.

Variable verbosity

  `int(0..) Tools.Standalone.process_files.verbosity`

Description

  0 in quiet mode, 1 by default, above = more output

Variable overwrite

  `int(0..1) Tools.Standalone.process_files.overwrite`

Description

  0 to make backups, 1 to overwrite (default)

Variable recursive

  `int(0..1) Tools.Standalone.process_files.recursive`

Description

  1 to recurse into directories, 0 not to (default)

Variable default_flag_docs

  `string Tools.Standalone.process_files.default_flag_docs`

Description

  Flag docs to append to your usage description. Explains default options.