Class SpartaCliProcessor

java.lang.Object
be.kuleuven.cs.distrinet.sparta.cli.SpartaCliProcessor
All Implemented Interfaces:
CliProcessor

public class SpartaCliProcessor extends Object implements CliProcessor
Command line processor. Every GenericCliCmd and Exporter can provide a list of options and will be called with the provided arguments to check if they need to perform any action.
  • Constructor Details

    • SpartaCliProcessor

      @Inject public SpartaCliProcessor(Set<GenericCliCmd> gens, Set<Exporter> exporters)
      Create a new SpartaCliProcessor.
      Parameters:
      gens - Set of generic command such as help, about, etc.
      exporters - Set of potential exporters to provide export functionality to csv, xlsx, etc.
  • Method Details

    • process

      public void process(String[] args)
      Process the provided command line arguments.
      Specified by:
      process in interface CliProcessor
      Parameters:
      args - the cli arguments
    • runThreatAnalysis

      public static List<Threat> runThreatAnalysis(String target)
      Run a threat analysis on user-specified model. The model file is retrieved from the cli arguments.
      Parameters:
      target - the model
      Returns:
      the resulting list of threats
    • runThreatAnalysis

      public static List<Threat> runThreatAnalysis(ResourceSet resourceSet)
      Run a threat analysis on an already-loaded model. Reusing a ResourceSet avoids parsing the same model more than once.
      Parameters:
      resourceSet - the resource set containing the loaded model
      Returns:
      the resulting list of threats
    • loadModel

      public static ResourceSet loadModel(String target)
      Load a model from the provided filename. This is a helper method that returns the ResourceSet. It does not run the threat analysis. To load a model and run the threat analysis use runThreatAnalysis.
      Parameters:
      target - the filename of the model
      Returns:
      the ResourceSet with the model.
    • registerGeneric

      public void registerGeneric(GenericCliCmd genCmd)
      Register a generic command with this cli processor. Its options will be taken into account.
      Parameters:
      genCmd - the GenericCliCmd to register
    • setupVIATRAStandalone

      public static void setupVIATRAStandalone()
      Setup VIATRA for running it outside of an eclipse instance.
    • setupEMFStandalone

      public static void setupEMFStandalone()
      Setup EMF for running it outside of an eclipse instance.
    • getOptions

      public org.apache.commons.cli.Options getOptions()
      Description copied from interface: CliProcessor
      Get the full set of command line options.
      Specified by:
      getOptions in interface CliProcessor
      Returns:
      the set of supported options.