Search in sources :

Example 6 with AlphaConfig

use of at.ac.tuwien.kr.alpha.api.config.AlphaConfig in project Alpha by alpha-asp.

the class CommandLineParserTest method atomSeparator.

@Test
public void atomSeparator() throws ParseException {
    CommandLineParser parser = new CommandLineParser(DEFAULT_COMMAND_LINE, DEFAULT_ABORT_ACTION);
    AlphaConfig cfg = parser.parseCommandLine(new String[] { "-str", "aString.", "-sep", "some-string" });
    assertEquals("some-string", cfg.getSystemConfig().getAtomSeparator());
}
Also used : AlphaConfig(at.ac.tuwien.kr.alpha.api.config.AlphaConfig) Test(org.junit.jupiter.api.Test)

Example 7 with AlphaConfig

use of at.ac.tuwien.kr.alpha.api.config.AlphaConfig in project Alpha by alpha-asp.

the class CommandLineParserTest method basicUsageWithFile.

@Test
public void basicUsageWithFile() throws ParseException {
    CommandLineParser parser = new CommandLineParser(DEFAULT_COMMAND_LINE, DEFAULT_ABORT_ACTION);
    AlphaConfig ctx = parser.parseCommandLine(new String[] { "-i", "someFile.asp", "-i", "someOtherFile.asp" });
    assertEquals(Arrays.asList(new String[] { "someFile.asp", "someOtherFile.asp" }), ctx.getInputConfig().getFiles());
}
Also used : AlphaConfig(at.ac.tuwien.kr.alpha.api.config.AlphaConfig) Test(org.junit.jupiter.api.Test)

Example 8 with AlphaConfig

use of at.ac.tuwien.kr.alpha.api.config.AlphaConfig in project Alpha by alpha-asp.

the class CommandLineParser method parseCommandLine.

public AlphaConfig parseCommandLine(String[] args) throws ParseException {
    CommandLine commandLine = new DefaultParser().parse(CommandLineParser.CLI_OPTS, args);
    if (commandLine.getArgs().length > 0) {
        throw new ParseException("Positional arguments { " + StringUtils.join(args, ' ') + " } are invalid!");
    }
    AlphaConfig retVal = new AlphaConfig();
    SystemConfig sysConf = new SystemConfig();
    InputConfig inputConf = new InputConfig();
    if (commandLine.hasOption(CommandLineParser.OPT_HELP.getOpt())) {
        LOGGER.debug("Found help option!");
        this.handleHelp();
    } else {
        this.validate(commandLine);
    }
    for (Option opt : commandLine.getOptions()) {
        this.handleOption(opt, sysConf, inputConf);
    }
    retVal.setSystemConfig(sysConf);
    retVal.setInputConfig(inputConf);
    return retVal;
}
Also used : CommandLine(org.apache.commons.cli.CommandLine) SystemConfig(at.ac.tuwien.kr.alpha.api.config.SystemConfig) AlphaConfig(at.ac.tuwien.kr.alpha.api.config.AlphaConfig) InputConfig(at.ac.tuwien.kr.alpha.api.config.InputConfig) Option(org.apache.commons.cli.Option) ParseException(org.apache.commons.cli.ParseException) DefaultParser(org.apache.commons.cli.DefaultParser)

Example 9 with AlphaConfig

use of at.ac.tuwien.kr.alpha.api.config.AlphaConfig in project Alpha by alpha-asp.

the class CommandLineParserTest method disableStratifiedEval.

@Test
public void disableStratifiedEval() throws ParseException {
    CommandLineParser parser = new CommandLineParser(DEFAULT_COMMAND_LINE, DEFAULT_ABORT_ACTION);
    AlphaConfig ctx = parser.parseCommandLine(new String[] { "-i", "someFile.asp", "-i", "someOtherFile.asp", "-dse" });
    assertFalse(ctx.getSystemConfig().isEvaluateStratifiedPart());
}
Also used : AlphaConfig(at.ac.tuwien.kr.alpha.api.config.AlphaConfig) Test(org.junit.jupiter.api.Test)

Example 10 with AlphaConfig

use of at.ac.tuwien.kr.alpha.api.config.AlphaConfig in project Alpha by alpha-asp.

the class CommandLineParserTest method noInstanceRemoval.

@Test
public void noInstanceRemoval() throws ParseException {
    CommandLineParser parser = new CommandLineParser(DEFAULT_COMMAND_LINE, DEFAULT_ABORT_ACTION);
    AlphaConfig alphaConfig = parser.parseCommandLine(new String[] { "-str", "aString.", "-acc" });
    assertTrue(alphaConfig.getSystemConfig().isGrounderAccumulatorEnabled());
}
Also used : AlphaConfig(at.ac.tuwien.kr.alpha.api.config.AlphaConfig) Test(org.junit.jupiter.api.Test)

Aggregations

AlphaConfig (at.ac.tuwien.kr.alpha.api.config.AlphaConfig)15 Test (org.junit.jupiter.api.Test)12 InputConfig (at.ac.tuwien.kr.alpha.api.config.InputConfig)3 ParseException (org.apache.commons.cli.ParseException)3 Alpha (at.ac.tuwien.kr.alpha.api.Alpha)2 DebugSolvingContext (at.ac.tuwien.kr.alpha.api.DebugSolvingContext)2 Solver (at.ac.tuwien.kr.alpha.api.Solver)2 StatisticsReportingSolver (at.ac.tuwien.kr.alpha.api.StatisticsReportingSolver)2 SystemConfig (at.ac.tuwien.kr.alpha.api.config.SystemConfig)2 AlphaImpl (at.ac.tuwien.kr.alpha.api.impl.AlphaImpl)2 ASPCore2Program (at.ac.tuwien.kr.alpha.api.programs.ASPCore2Program)2 CommandLineParser (at.ac.tuwien.kr.alpha.app.config.CommandLineParser)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 AnswerSet (at.ac.tuwien.kr.alpha.api.AnswerSet)1 NormalProgram (at.ac.tuwien.kr.alpha.api.programs.NormalProgram)1 ComponentGraph (at.ac.tuwien.kr.alpha.api.programs.analysis.ComponentGraph)1 DependencyGraph (at.ac.tuwien.kr.alpha.api.programs.analysis.DependencyGraph)1 AnswerSetFormatter (at.ac.tuwien.kr.alpha.api.util.AnswerSetFormatter)1 ComponentGraphWriter (at.ac.tuwien.kr.alpha.app.ComponentGraphWriter)1