Class PathplannerSearch
Utility class that gives search features that Pathplanner lacks
This class is meant to help search for where paths and linked variables are used so you can clean up unused ones.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidexecute(Map<Main.ARGUMENTS, Object> parsedArgs) Functionalitystatic voidlogFiles(String searchTerm, PathplannerSearch.SearchType searchType, List<String> matches) Logs the result of the search to the console with some formatting.static StringparseFolderKeyFromFileContent(String content) Parses the "folder" key from the content of a .path file.Methods inherited from class tools.ToolClasses.ArgumentedTool
run
-
Constructor Details
-
PathplannerSearch
public PathplannerSearch()
-
-
Method Details
-
execute
Functionality
Searches through .path files in
src/main/deploy/pathplannerand logs files that match a certain search term based on the search type.- Specified by:
executein classArgumentedTool<Main.ARGUMENTS>- Parameters:
parsedArgs- the parsed arguments
-
parseFolderKeyFromFileContent
Parses the "folder" key from the content of a .path file.As Java doesn't have a built in JSON parser and for only having to do this once, it would be overkill to add a dependency.
This method uses regex to parse the "folder" key from the .path file.
.pathfiles are essentially just JSON files but with a different extension.- Parameters:
content- the content of the .path file- Returns:
- the value of the "folder" key in the .path file, or an empty string if it doesn't exist
-
logFiles
public static void logFiles(String searchTerm, PathplannerSearch.SearchType searchType, List<String> matches) Logs the result of the search to the console with some formatting.Uses ANSI color codes for coloring the output.
If no matches are found, it will log "None were found." in red.
Otherwise, it will log the list of matches in green on separate lines.
Example input and output:
./gradlew runPathPlannersearch -Pargs="disrupt path"
Autons that use the path 'disrupt': disrupt/LB Disrupt.auto disrupt/LT Disrupt.auto disrupt/RB Disrupt.auto disrupt/RT Disrupt.auto
- Parameters:
searchTerm-searchType-matches-
-