Skip to content

Commit c602522

Browse files
committed
ST6RI-178 Added %projects and %load to SysMLInteractive::run().
- Also corrected the incrementing of "counter" in the %projects and %load commands.
1 parent 957cfe8 commit c602522

1 file changed

Lines changed: 20 additions & 7 deletions

File tree

org.omg.sysml.interactive/src/org/omg/sysml/interactive/SysMLInteractive.java

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*****************************************************************************
22
* SysML 2 Pilot Implementation
3-
* Copyright (c) 2019-2022, 2024 Model Driven Solutions, Inc.
3+
* Copyright (c) 2019-2022, 2024, 2025 Model Driven Solutions, Inc.
44
* Copyright (c) 2020 Mgnite Inc.
55
* Copyright (c) 2021 Twingineer LLC
66
*
@@ -467,7 +467,7 @@ protected String publish(String name) {
467467
* @return output of the command
468468
*/
469469
public String load(Map<String, String> parameters) {
470-
470+
this.counter++;
471471
if (parameters.containsKey(HELP_KEY)) {
472472
return SysMLInteractiveHelp.getLoadHelp();
473473
}
@@ -494,7 +494,7 @@ public String load(Map<String, String> parameters) {
494494
}
495495

496496
if (project == null) {
497-
return "ERROR:Project doesn't exist.";
497+
return "ERROR:Project doesn't exist\n";
498498
}
499499

500500
final RemoteBranch branch;
@@ -515,7 +515,7 @@ public String load(Map<String, String> parameters) {
515515

516516
private String load(RemoteBranch branch) {
517517
if (branch == null) {
518-
return "ERROR:Branch doesn't exist";
518+
return "ERROR:Branch doesn't exist\n";
519519
}
520520

521521
System.out.println("Selected branch " + branch.getName());
@@ -553,16 +553,17 @@ private String load(RemoteBranch branch) {
553553
addResourceToIndex(xmiResource);
554554
});
555555

556-
return "Loaded Project " + remoteProject.getProjectName() + " (" + remoteProject.getRemoteId().toString() + ")";
556+
return "Loaded Project " + remoteProject.getProjectName() + " (" + remoteProject.getRemoteId().toString() + ")\n";
557557
}
558558

559-
protected String download(String name) {
559+
protected String load(String name) {
560560
return "-h".equals(name)?
561561
load(Map.of(HELP_KEY, "true")):
562562
load(Map.of(PROJECT_NAME_KEY, name));
563563
}
564564

565565
public String projects(List<String> help) {
566+
this.counter++;
566567
if (help != null && !help.isEmpty()) {
567568
return SysMLInteractiveHelp.getProjectsHelp();
568569
}
@@ -576,7 +577,13 @@ public String projects(List<String> help) {
576577
.sorted((p1, p2) -> projectNameComparator.compare(p1.getProjectName(), p2.getProjectName()))
577578
.map(p -> String.format("Project %s (%s)", p.getProjectName(), p.getRemoteId()))
578579
.collect(Collectors.joining("\n"));
579-
return apiBasePathString + "\n\n" + projectsListString;
580+
return apiBasePathString + "\n\n" + projectsListString + "\n";
581+
}
582+
583+
protected String projects(String arg) {
584+
return "-h".equals(arg)?
585+
projects(Collections.singletonList("true")):
586+
projects(Collections.emptyList());
580587
}
581588

582589
protected ApiElementProcessingFacade getApiElementProcessingFacade(String modelName, String branchName, boolean includeDerived) {
@@ -759,10 +766,16 @@ public void run() {
759766
if (!"".equals(argument)) {
760767
System.out.print(this.show(argument));
761768
}
769+
} else if ("%projects".equals(command)) {
770+
System.out.print(this.projects(argument));
762771
} else if ("%publish".equals(command)) {
763772
if (!"".equals(argument)) {
764773
System.out.print(this.publish(argument));
765774
}
775+
} else if ("%load".equals(command)) {
776+
if (!"".equals(argument)) {
777+
System.out.print(this.load(argument));
778+
}
766779
} else if ("%viz".equals(command)) {
767780
if (!"".equals(argument)) {
768781
System.out.print(this.viz(argument));

0 commit comments

Comments
 (0)