Package com.wnm3.gitignorezipper
Class GitIgnoreZipper
- java.lang.Object
-
- com.wnm3.gitignorezipper.GitIgnoreZipper
-
public class GitIgnoreZipper extends Object
Utility to recusively examine .gitignore files to determine what is not being stored in github repositories (e.g., customer data, certificates) and create an input file that zip can use to capture these files. An optional .overrides file can be used to keep .gitignored files from being added to the output file (e.g., zipper.files) to reduce the size of the resulting zip file.- Author:
- wnm3
-
-
Constructor Summary
Constructors Constructor Description GitIgnoreZipper()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcloseTextFile(BufferedReader br)Close a buffered reader opened usingopenTextFile(String)List<Path>listFiles(Path dir)Construct and return a sorted list of files in a directory identified by the dirList<Path>listFiles(Path dir, String ext)Construct and return a sorted list of files in a directory identified by the dir that have extensions matching the extList<Path>listSubdirectories(Path dir)Construct and return a sorted list of directories in a directory identified by the dir variableList<String>loadTextFile(String fqFilename)Reads the lines of a text file into a list of strings and returns that list.static voidmain(String[] args)Entry point to run this utility.BufferedReaderopenTextFile(String fqFilename)Stringprompt(String strPrompt)Print the supplied prompt (if not null) and return the trimmed responseStringprompt(String strPrompt, boolean bTrim)Print the supplied prompt (if not null) and return the trimmed response according to the supplied trim controlvoidsaveTextFile(String textFileName, String content)Save the specified JSONObject in serialized form to the specified file or throw the appropriate exception.
-
-
-
Method Detail
-
main
public static void main(String[] args)
Entry point to run this utility.- Parameters:
args- output file name (e.g., zipper.files), input directory (e.g., the directory to be searched recursively for .gitignore files to determine what has been left out of github repos to include in the output file, overrides file name (e.g., .overrides) listing directories and file names to be left out of the output file.
-
closeTextFile
public void closeTextFile(BufferedReader br)
Close a buffered reader opened usingopenTextFile(String)- Parameters:
br-
-
listFiles
public List<Path> listFiles(Path dir) throws IOException
Construct and return a sorted list of files in a directory identified by the dir- Parameters:
dir- the path to the directory containing files to be returned in the list- Returns:
- sorted list of files in a directory identified by the dir
- Throws:
IOException- if there is difficulty accessing the files in the supplied dir
-
listFiles
public List<Path> listFiles(Path dir, String ext) throws IOException
Construct and return a sorted list of files in a directory identified by the dir that have extensions matching the ext- Parameters:
dir- the path to the directory containing files to be returned in the listext- the file extension (without the leading period) used to filter files in the dir. If ext is an empty string then all files are returned.- Returns:
- sorted list of files in a directory identified by the dir that have extensions matching the ext
- Throws:
IOException- if there is difficulty accessing the files in the supplied dir
-
listSubdirectories
public List<Path> listSubdirectories(Path dir) throws IOException
Construct and return a sorted list of directories in a directory identified by the dir variable- Parameters:
dir- the path to the directory containing directories to be returned in the list- Returns:
- sorted list of subdirectories in a directory identified by the dir
- Throws:
IOException- if there is difficulty accessing the content in the supplied dir
-
loadTextFile
public List<String> loadTextFile(String fqFilename) throws Exception
Reads the lines of a text file into a list of strings and returns that list. If no lines are present (e.g., empty file) then an empty list is returned.- Parameters:
fqFilename- fully qualified filename- Returns:
- list of strings read from the file
- Throws:
Exception- if the file can not be read.
-
openTextFile
public BufferedReader openTextFile(String fqFilename) throws Exception
- Parameters:
fqFilename- fully qualified name of the text file to be opened- Returns:
- open buffered reader to allow individual lines of a text file to be read
- Throws:
Exception- See Also:
to close the reader returned by this function
-
prompt
public String prompt(String strPrompt)
Print the supplied prompt (if not null) and return the trimmed response- Parameters:
strPrompt-- Returns:
- the trimmed response to the prompt (may be the empty String ("") if nothing entered)
-
prompt
public String prompt(String strPrompt, boolean bTrim)
Print the supplied prompt (if not null) and return the trimmed response according to the supplied trim control- Parameters:
strPrompt-bTrim-- Returns:
- the trimmed response (if so commanded) to the prompt (may be the empty String ("") if nothing entered)
-
saveTextFile
public void saveTextFile(String textFileName, String content) throws Exception
Save the specified JSONObject in serialized form to the specified file or throw the appropriate exception.- Parameters:
textFileName- fully qualified name of the JSON file to be savedcontent- the content to be saved to a file.- Throws:
Exception-IOException) if there is a problem writing the file
-
-