Class GenerateCommand

  • All Implemented Interfaces:
    java.util.concurrent.Callable<java.lang.Integer>

    public class GenerateCommand
    extends CommandCommons
    This class handles the generation command
    • Constructor Summary

      Constructors 
      Constructor Description
      GenerateCommand()
      Constructor needed for Picocli
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean areArgumentsValid()
      Validates the user arguments in the context of the generate command.
      java.lang.Integer doAction()  
      <T extends com.devonfw.cobigen.api.to.GenerableArtifact>
      void
      generate​(java.nio.file.Path inputFile, java.lang.Object input, java.nio.file.Path inputProject, java.util.List<T> generableArtifacts, com.devonfw.cobigen.api.CobiGen cg, java.lang.Class<T> c)
      Generates new templates or increments using the inputFile from the inputProject.
      static java.lang.String getUserInput()
      Asks the user for input and returns the value
      static java.io.File preprocessInputFile​(java.io.File inputFile)
      Processes the input file's path.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GenerateCommand

        public GenerateCommand()
        Constructor needed for Picocli
    • Method Detail

      • doAction

        public java.lang.Integer doAction()
                                   throws java.lang.Exception
        Specified by:
        doAction in class CommandCommons
        Throws:
        java.lang.Exception
      • areArgumentsValid

        public boolean areArgumentsValid()
        Validates the user arguments in the context of the generate command. Tries to check whether all the input files and the output root path are valid.
        Returns:
        true when these arguments are correct
      • generate

        public <T extends com.devonfw.cobigen.api.to.GenerableArtifact> void generate​(java.nio.file.Path inputFile,
                                                                                      java.lang.Object input,
                                                                                      java.nio.file.Path inputProject,
                                                                                      java.util.List<T> generableArtifacts,
                                                                                      com.devonfw.cobigen.api.CobiGen cg,
                                                                                      java.lang.Class<T> c)
        Generates new templates or increments using the inputFile from the inputProject.
        Type Parameters:
        T - type of generable artifacts to generate
        Parameters:
        inputFile - input file to be selected by the user
        input - parsed by CobiGen read method
        inputProject - input project where the input file is located. We need this in order to build the classpath of the input file
        generableArtifacts - the list of increments or templates that the user is going to use for generation
        cg - Initialized CobiGen instance
        c - class type, specifies whether Templates or Increments should be preprocessed
      • getUserInput

        public static java.lang.String getUserInput()
        Asks the user for input and returns the value
        Returns:
        String containing the user input
      • preprocessInputFile

        public static java.io.File preprocessInputFile​(java.io.File inputFile)
        Processes the input file's path. Strips the quotes from the file path if they are given.
        Parameters:
        inputFile - the input file
        Returns:
        input file with processed path