public final class Main extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Main.AddConditions
This bean represents the various "conditions" command line options of the "--add" action.
|
static class |
Main.Conditions
The base class of the various "conditions" command line options beans.
|
static class |
Main.ExitException
Dictates that the command line tool should
Printers.info(String) the exception's message, and then
System.exit(int) with the given status. |
static class |
Main.PatchConditions
This bean represents the various "conditions" command line options of the "--patch" action.
|
static class |
Main.RemoveConditions
This bean represents the various "conditions" command line options of the "--remove" action.
|
static class |
Main.RenameConditions
This bean represents the various "conditions" command line options of the "--rename" action.
|
static class |
Main.SubstituteConditions
This bean represents the various "conditions" command line options of the "--substitute" action.
|
static class |
Main.UpdateConditions
This bean represents the various "conditions" command line options of the "--update" action.
|
Constructor and Description |
---|
Main() |
Modifier and Type | Method and Description |
---|---|
void |
addAdd(de.unkrig.commons.text.pattern.Glob glob,
String name,
File contentsFile,
Main.AddConditions addConditions)
To all directories and archives that match glob, add a member/entry name, and fill it
from contents-file.
|
static void |
addLog(String spec)
Add logging at level
FINE on logger "de.unkrig " to STDERR using the "FormatFormatter "
and "SIMPLE " format, or the given arguments, which are all optional. |
void |
addPatch(de.unkrig.commons.text.pattern.Glob glob,
File patchFile,
Main.PatchConditions patchConditions)
Apply patch-file to all files/archive entries that match glob (see below).
|
void |
addRemove(de.unkrig.commons.text.pattern.Glob glob,
Main.RemoveConditions removeConditions)
Remove all files/archive entries that match glob (see below).
|
void |
addRename(de.unkrig.commons.text.pattern.Glob glob,
Main.RenameConditions renameConditions)
Rename files/archive entries according to glob (see below), e.g.
|
void |
addSubstitute(de.unkrig.commons.text.pattern.Glob glob,
Pattern pattern,
String replacement,
Main.SubstituteConditions substituteConditions)
Replace all matches of pattern in files/archive entries that match glob (see below) with
the replacement string, which supports:
"
$0 ", "$1 ", "$2 ", etc. expand to the captured groups of the match. |
void |
addUpdate(de.unkrig.commons.text.pattern.Glob specification,
Main.UpdateConditions updateConditions)
Replace the contents of files/archive entries that match glob (see below) with that of the
update-file.
|
void |
check()
Do not create or modify any files; exit with status 1 if this is an in-place transformation, and at least one of
the files would be changed.
|
void |
checkBeforeTransformation()
Before modifying a file, check whether the change is redundant, i.e. yields an identical result.
|
void |
dontSortDirectoryMembers()
By default directory members are processed in lexicographical sequence to achieve deterministic results.
|
static void |
help()
Print this text and terminate.
|
void |
keep()
If existing files would be overwritten, keep copies of the originals.
|
void |
keepGoing()
Print error and continue with next file.
|
void |
lookInto(de.unkrig.commons.text.pattern.Glob glob)
Look into compressed and archive contents if the format and the path match the glob.
|
static void |
main(String[] args)
Usage
zzpatch [ option ... ]
Transforms STDIN to STDOUT. |
void |
main3(String[] args) |
void |
set7zInputFilePassword(String value)
Password to decrypt password-protected 7ZIP input files.
|
void |
setDebug()
Print verbose and debug messages.
|
void |
setEncoding(Charset charset)
All of "--patch-file-encoding", "--input-encoding" and "--output-encoding".
|
void |
setInputEncoding(Charset charset)
Encoding of input files (only relevant for "
--substitute " and "--patch "); the default is "${file.encoding} ". |
void |
setNowarn()
Suppress all messages except errors.
|
void |
setOutputEncoding(Charset charset)
Encoding of output files (only relevant for "
--substitute " and "--patch "); the default is "${file.encoding} ". |
void |
setPassword(String value)
All of the above.
|
void |
setPatchFileEncoding(Charset charset)
Encoding of patch files (only relevant for "
--patch "); the default is "${file.encoding} ". |
void |
setQuiet()
Suppress normal output.
|
void |
setVerbose()
Print verbose messages.
|
void |
setZipInputFilePassword(String value)
Password to decrypt password-protected zip archive entries.
|
void |
setZipOutputEntryCompressionLevel(net.lingala.zip4j.model.enums.CompressionLevel value)
Compression level of zip archive entries.
|
void |
setZipOutputFileEncryptionMethod(net.lingala.zip4j.model.enums.EncryptionMethod value)
Method to encrypt password-protected zip archive entries.
|
void |
setZipOutputFilePassword(String value)
Password to encrypt password-protected zip archive entries (sets encryption method to ZIP_STANDARD).
|
public static void main(String[] args)
zzpatch
[ option ... ]zzpatch
[ option ... ] file-or-dirzzpatch
[ option ... ] file-or-dir new-file-or-dirzzpatch
[ option ... ] file-or-dir ... existing-dirThese control the preceding file transformation.
--report
exprpath + ": Add '" + name + "' from '" + contentsFile + "'"
". The parameters of the expr
depend on the file transformation (see above).
--iff
exprCheck the descriptions of wildcards, includes / excludes and replacements.
Examples:
dir/file
file.gz%
file.zip!dir/file
file.tar.gz%!dir/file
dir/file
" in the compressed archive file "file.tar.gz
"
*/x
x
" in an immediate subdirectory
**/x
x
" in any subdirectory
***/x
x
" in any subdirectory, or any entry "**/x
" in any archive file in any
subdirectory
a,dir/file.7z!dir/b
a
" and entry "dir/b
" in archive file "dir/file.7z
"
~*.c
.c
"
~*.c~*.h
.c
" or ".h
"
~*.c~*.h,foo.c
foo.c
" plus all files that don't end with ".c
" or ".h
"
For the precise description of the supported regular-expression constructs, see here.
For the precise description of the replacement format, see here.
For the precise description of the supported expression constructs, see here.
public void lookInto(de.unkrig.commons.text.pattern.Glob glob)
${archive.formats}
${compression.formats}
glob
- format-glob:
path-globpublic void dontSortDirectoryMembers()
public void setPatchFileEncoding(Charset charset)
--patch
"); the default is "${file.encoding}
".public void check()
"--check --verbose
" also prints the path of the first file or archive entry that would be
changed.
"--check --verbose --keep-going
" prints the pathes of all files and archive entries that
would be changed.
public void checkBeforeTransformation()
public void keep()
public void addUpdate(de.unkrig.commons.text.pattern.Glob specification, Main.UpdateConditions updateConditions)
specification
- glob=
update-fileupdateConditions
- [ condition ... ]public void addSubstitute(de.unkrig.commons.text.pattern.Glob glob, Pattern pattern, String replacement, Main.SubstituteConditions substituteConditions) throws de.unkrig.commons.text.parser.ParseException
$0
", "$1
", "$2
", etc. expand to the captured groups of the match.${...}
" is expanded as an expression, e.g. "${m.group().toUpperCase()}
"xutnrfaebQE
" are supported as in a regex
Conditions (see below) apply per match; the parameters of the "--report
" and "--iff
"
conditions are:
substituteConditions
- [ condition ... ]de.unkrig.commons.text.parser.ParseException
public void addPatch(de.unkrig.commons.text.pattern.Glob glob, File patchFile, Main.PatchConditions patchConditions) throws IOException, de.unkrig.commons.text.StringStream.UnexpectedElementException
Conditions (see below) apply per match; the parameters of the "--report
" and "--iff
"
conditions are:
patchConditions
- [ condition ... ]de.unkrig.commons.text.StringStream.UnexpectedElementException
- The patchFile
does not contain a valid DIFF documentIOException
public void addRemove(de.unkrig.commons.text.pattern.Glob glob, Main.RemoveConditions removeConditions)
removeConditions
- [ condition ... ]public void addRename(de.unkrig.commons.text.pattern.Glob glob, Main.RenameConditions renameConditions)
(*).c=$1.c.orig
".
Multiple "--rename
" options are applied in the given order.renameConditions
- [ condition ... ]public void addAdd(de.unkrig.commons.text.pattern.Glob glob, String name, File contentsFile, Main.AddConditions addConditions)
addConditions
- [ condition ... ]public void setInputEncoding(Charset charset)
--substitute
" and "--patch
"); the default is "${file.encoding}
".public void setOutputEncoding(Charset charset)
--substitute
" and "--patch
"); the default is "${file.encoding}
".public void setEncoding(Charset charset)
public static void help() throws IOException
IOException
public void keepGoing()
public void setZipOutputEntryCompressionLevel(net.lingala.zip4j.model.enums.CompressionLevel value)
public void set7zInputFilePassword(String value)
public void setZipInputFilePassword(String value)
public void setZipOutputFilePassword(String value)
public void setPassword(String value)
public void setZipOutputFileEncryptionMethod(net.lingala.zip4j.model.enums.EncryptionMethod value)
public void setNowarn()
public void setQuiet()
public void setVerbose()
public void setDebug()
public static void addLog(String spec)
FINE
on logger "de.unkrig
" to STDERR using the "FormatFormatter
"
and "SIMPLE
" format, or the given arguments, which are all optional.spec
- level:
logger:
handler:
formatter:
formatpublic void main3(String[] args) throws IOException
IOException
Copyright © 2022 Arno Unkrig. All rights reserved.