java.lang.Object
org.variantsync.studies.evolution.simulation.shell.ShellCommand
org.variantsync.studies.evolution.simulation.shell.PatchCommand

public class PatchCommand extends ShellCommand
Represents a shell 'patch' command that can be executed using a ShellExecutor
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Assume that the user knows exactly what he or she is doing, and do not ask any questions.
    When a patch does not apply, patch usually checks if the patch looks like it has been applied already by trying to reverse- apply the first hunk.
    input(Path patchFile)
    Read the patch from patchfile.
    Do not back up a file if the patch does not match the file exactly and if backups are not otherwise requested.
    outfile(Path outputPath)
    Send output to outfile instead of patching files in place.
    Return the String parts that define and configure the command execution (e.g., ["echo", "Hello World"])
    Recommended(Path patchFile)
    A PatchCommand configured as recommended in the documentation of 'patch'
    rejectFile(Path rejectPath)
    Put rejects into rejectPath instead of the default .rej file.
    strip(int number)
    Strip the smallest prefix containing num leading slashes from each file name found in the patch file.
     

    Methods inherited from class org.variantsync.studies.evolution.simulation.shell.ShellCommand

    interpretResult

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • PatchCommand

      public PatchCommand()
  • Method Details

    • Recommended

      public static PatchCommand Recommended(Path patchFile)
      A PatchCommand configured as recommended in the documentation of 'patch'
      Parameters:
      patchFile - The file containing the patch
      Returns:
      A configured PatchCommand
    • forward

      public PatchCommand forward()
      When a patch does not apply, patch usually checks if the patch looks like it has been applied already by trying to reverse- apply the first hunk. The --forward option prevents that. See also -R.
      Returns:
      this command
    • strip

      public PatchCommand strip(int number)
      Strip the smallest prefix containing num leading slashes from each file name found in the patch file. A sequence of one or more adjacent slashes is counted as a single slash. This controls how file names found in the patch file are treated, in case you keep your files in a different directory than the person who sent out the patch. For example, supposing the file name in the patch file was
      Parameters:
      number - how many leading slashes to slash from the file name
      Returns:
      this command
    • outfile

      public PatchCommand outfile(Path outputPath)
      Send output to outfile instead of patching files in place. Do not use this option if outfile is one of the files to be patched. When outfile is -, send output to standard output, and send any messages that would usually go to standard output to standard error.
      Parameters:
      outputPath - The outfile path
      Returns:
      this command
    • rejectFile

      public PatchCommand rejectFile(Path rejectPath)
      Put rejects into rejectPath instead of the default .rej file. When rejectfile is -, discard rejects.
    • input

      public PatchCommand input(Path patchFile)
      Read the patch from patchfile. If patchfile is -, read from standard input, the default.
      Parameters:
      patchFile - the file to load
      Returns:
      this command
    • noBackup

      public PatchCommand noBackup()
      Do not back up a file if the patch does not match the file exactly and if backups are not otherwise requested. This is the default if patch is conforming to POSIX.
      Returns:
      this command
    • force

      public PatchCommand force()
      Assume that the user knows exactly what he or she is doing, and do not ask any questions. Skip patches whose headers do not say which file is to be patched; patch files even though they have the wrong version for the Prereq: line in the patch; and assume that patches are not reversed even if they look like they are.
      Returns:
      this command
    • parts

      public String[] parts()
      Description copied from class: ShellCommand
      Return the String parts that define and configure the command execution (e.g., ["echo", "Hello World"])
      Specified by:
      parts in class ShellCommand
      Returns:
      the parts of the shell command.
    • toString

      public String toString()
      Overrides:
      toString in class ShellCommand