Skip to content

Commit 7e36f12

Browse files
committed
ST6RI-836 Changed magic command 'api-base-path' to 'repo'
- updated help string - fixed '-h' flag
1 parent 9b4a979 commit 7e36f12

2 files changed

Lines changed: 16 additions & 15 deletions

File tree

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,20 @@
3232
import java.util.Map;
3333

3434
import org.omg.sysml.plantuml.SysML2PlantUMLStyle;
35+
import org.omg.sysml.util.traversal.facade.impl.ApiElementProcessingFacade;
3536

3637
public class SysMLInteractiveHelp {
3738

3839
private static final String GENERAL_HELP_STRING =
3940
"The following SysML v2 magic commands are available.\n"
4041
+ "For help on a specific command, use \"%help <COMMAND>\" or \"%<cmd> -h\".\n\n"
41-
+ "%api-base-path\t Sets and prints the current api base path"
42+
+ "%repo\t Set the api base path for the repository"
4243
+ "%eval\t\tEvaluate a given expression.\n"
4344
+ "%export\t\tSave a file of the JSON representation of the abstract syntax tree rooted in the named element.\n"
4445
+ "%help\t\tGet a list of available commands or help on a specific command\n"
4546
+ "%list\t\tList loaded library packages or the results of a given query\n"
4647
+ "%show\t\tPrint the abstract syntax tree rooted in a named element\n"
47-
+ "%publish\tPublish to the repository the modele elements rooted in a named element\n"
48+
+ "%publish\tPublish to the repository the model elements rooted in a named element\n"
4849
+ "%view\t\tRender the view specified by the named view usage\n"
4950
+ "%viz\t\tVisualize the name model elements\n";
5051

@@ -118,9 +119,12 @@ public class SysMLInteractiveHelp {
118119
+ "<NAME> must be fully qualified.\n";
119120

120121
private static final String API_BASE_PATH_HELP_STRING =
121-
"Usage: %api-base-path [<BASE PATH>]\n\n"
122-
+ "Sets the current api base path\n"
123-
+ "If no argument is passed it prints the current api base path";
122+
"Usage: %repo [<BASE PATH>]\n\n"
123+
+ "If <BASE PATH> is not given, print the current repository base path.\r\n"
124+
+ "If <BASE PATH> is given, set the repository base path.\r\n"
125+
+ "\r\n"
126+
+ "<BASE PATH> is a URL giving the API base path for the repository access by the %projects, %publish and %load commands. \r\n"
127+
+ "For example: " + ApiElementProcessingFacade.DEFAULT_BASE_PATH;
124128

125129
public static String getGeneralHelp() {
126130
return GENERAL_HELP_STRING;
@@ -173,7 +177,8 @@ private static Map<String, String> createCommandHelpMap() {
173177
map.put("%publish", PUBLISH_HELP_STRING);
174178
map.put("%viz", VIZ_HELP_STRING);
175179
map.put("%view", VIEW_HELP_STRING);
176-
map.put("%export", EXPORT_HELP_STRING);
180+
map.put("%export", EXPORT_HELP_STRING);
181+
map.put("%repo", API_BASE_PATH_HELP_STRING);
177182
return map;
178183
}
179184

org.omg.sysml.jupyter.kernel/src/main/java/org/omg/sysml/jupyter/kernel/magic/ApiBasePath.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,19 @@
3333

3434
public class ApiBasePath {
3535

36-
private static final MagicsArgs SHOW_ARGS = MagicsArgs.builder().onlyKnownKeywords().onlyKnownFlags()
36+
private static final MagicsArgs REPO_ARGS = MagicsArgs.builder().onlyKnownKeywords().onlyKnownFlags()
3737
.optional("basePath")
3838
.flag("help", 'h', "true")
3939
.build();
4040

41-
@LineMagic("api-base-path")
41+
@LineMagic("repo")
4242
public static String apiBasePath(List<String> args) {
43-
Map<String, List<String>> vals = SHOW_ARGS.parse(args);
43+
Map<String, List<String>> vals = REPO_ARGS.parse(args);
4444
List<String> basePaths = vals.get("basePath");
45+
List<String> help = vals.get("help");
4546
String basePath = basePaths.isEmpty()? null: basePaths.get(0);
4647

4748
SysMLInteractive interactive = ISysML.getKernelInstance().getInteractive();
48-
49-
if (basePath != null) {
50-
interactive.setApiBasePath(basePath);
51-
}
52-
53-
return "Api base path is: " + ISysML.getKernelInstance().getInteractive().getApiBasePath();
49+
return interactive.apiBasePath(basePath, help);
5450
}
5551
}

0 commit comments

Comments
 (0)