Package com.devonfw.cobigen.cli.commands
Class GenerateCommand
- java.lang.Object
-
- com.devonfw.cobigen.cli.commands.CommandCommons
-
- com.devonfw.cobigen.cli.commands.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 booleanareArgumentsValid()Validates the user arguments in the context of the generate command.java.lang.IntegerdoAction()<T extends com.devonfw.cobigen.api.to.GenerableArtifact>
voidgenerate(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.StringgetUserInput()Asks the user for input and returns the valuestatic java.io.FilepreprocessInputFile(java.io.File inputFile)Processes the input file's path.-
Methods inherited from class com.devonfw.cobigen.cli.commands.CommandCommons
call
-
-
-
-
Method Detail
-
doAction
public java.lang.Integer doAction() throws java.lang.Exception- Specified by:
doActionin classCommandCommons- 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 userinput- parsed by CobiGen read methodinputProject- input project where the input file is located. We need this in order to build the classpath of the input filegenerableArtifacts- the list of increments or templates that the user is going to use for generationcg- Initialized CobiGen instancec- 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
-
-