Class MakefileRecipeReader

java.lang.Object
za.co.wethinkcode.robots.cli.help.MakefileRecipeReader

public class MakefileRecipeReader extends Object
Reads the recipe (the tab-indented command lines) for a single target out of the project's Makefile.

This exists so the launch-help output stays in sync with the Makefile automatically. If someone changes what make server actually runs, the CLI help updates itself instead of drifting out of date.

Recipes can span multiple tab-indented lines (see test-own in the Makefile), so every consecutive tab-indented line following the target header is treated as part of that target's recipe.

  • Constructor Details

    • MakefileRecipeReader

      public MakefileRecipeReader()
      Reads from the Makefile at the project root (relative to the working directory).
    • MakefileRecipeReader

      public MakefileRecipeReader(Path makefilePath)
      Reads from an explicit Makefile path, mainly useful for testing.
  • Method Details

    • readRecipe

      public Optional<List<String>> readRecipe(String targetName)
      Reads the recipe for the given target name.
      Parameters:
      targetName - the Makefile target, e.g. "server" or "client"
      Returns:
      the recipe lines in order, or Optional.empty() if the Makefile couldn't be read or the target wasn't found