Skip to content

Commit

Permalink
add --jason in jason agent mind
Browse files Browse the repository at this point in the history
  • Loading branch information
jomifred committed Oct 16, 2024
1 parent 9c6fa56 commit cb4eab3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
26 changes: 20 additions & 6 deletions jason-cli/src/main/java/jason/cli/agent/MindAgent.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ public class MindAgent extends BaseAgent implements Runnable {
@CommandLine.Option(names = { "--mas-name" }, paramLabel = "<mas name>", defaultValue = "", description = "MAS unique identification")
String masName;

@CommandLine.Option(names = { "--json" }, defaultValue = "false", description = "output in JSON format (only for beliefs)")
boolean json;

@Override
public void run() {
masName = testMasName(masName, parent.parent);
Expand Down Expand Up @@ -65,6 +68,9 @@ public void run() {

void showBeliefs(jason.asSemantics.Agent ag) {
var out = new StringBuilder();
var v = "";
if (json)
out.append("[ ");
for (var ns: ag.getBB().getNameSpaces()) {
if (ns.toString().equals("kqml"))
continue;
Expand All @@ -77,19 +83,27 @@ void showBeliefs(jason.asSemantics.Agent ag) {
first = false;
}
// remove namespace
var bs = b.toString();
var p = bs.indexOf("::");
if (p>0)
bs = bs.substring(p+2);
out.append(" "+bs+"\n");
if (json) {
out.append(v+b.getAsJsonStr());
v = ",";
} else {
var bs = b.toString();
var p = bs.indexOf("::");
if (p > 0)
bs = bs.substring(p + 2);
out.append(" " + bs + "\n");
}
}
}
}
if (json) {
out.append(" ]");
}
parent.parent.println( out.toString());
}

void showPlans(jason.asSemantics.Agent ag) {
parent.parent.println( ag.getPL().getAsTxt(false).trim());
parent.parent.println(ag.getPL().getAsTxt(false).trim());
}

void showIntentions(jason.asSemantics.Agent ag) {
Expand Down
3 changes: 3 additions & 0 deletions jason-cli/src/main/java/jason/cli/app/Gradle.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ public class Gradle extends Common implements Runnable {
@Override
public void run() {
var created = getOrCreateGradleFile( "" );
if (!created) {
parent.parent.println("using existing build.gradle");
}
try (var connection = getGradleConnection(new File("." ))) { //gradleFile.getAbsoluteFile().getParentFile())
getGradleBuild(connection)
.forTasks("wrapper")
Expand Down

0 comments on commit cb4eab3

Please sign in to comment.