Class PathplannerSearch

java.lang.Object
tools.ToolClasses.ArgumentedTool<Main.ARGUMENTS>
tools.PathplannerSearch.PathplannerSearch

public final class PathplannerSearch extends ArgumentedTool<Main.ARGUMENTS>

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.

  • Constructor Details

  • Method Details

    • execute

      protected void execute(Map<Main.ARGUMENTS,Object> parsedArgs)

      Functionality

      Searches through .path files in src/main/deploy/pathplanner and logs files that match a certain search term based on the search type.

      Specified by:
      execute in class ArgumentedTool<Main.ARGUMENTS>
      Parameters:
      parsedArgs - the parsed arguments
    • parseFolderKeyFromFileContent

      public static String parseFolderKeyFromFileContent(String content)
      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. .path files 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 -