Class CommandLine
- java.lang.Object
-
- com.nomagic.magicdraw.commandline.CommandLine
-
- Direct Known Subclasses:
ProjectCommandLine
@OpenApiAll public abstract class CommandLine extends java.lang.Object
MagicDraw commandline launcher.
Extend it and implementexecute()
method. Code sample:public class TestCommandLine extends CommandLine { public static void main(String[] args) { new TestCommandLine().launch(args); } protected void execute() { // load project File fileToLoad = new File("myProject.mdzip"); ProjectDescriptor descriptor = ProjectDescriptorsFactory.createProjectDescriptor(fileToLoad.toURI()); ProjectsManager projectsManager = Application.getInstance().getProjectsManager(); projectsManager.loadProject(descriptor, true); Project project = Application.getInstance().getProject(); // "save as" project File fileToSave = new File("myProject2.mdzip"); ProjectDescriptor localProjectDescriptor = ProjectDescriptorsFactory.createLocalProjectDescriptor(project, fileToSave); projectsManager.saveProject(localProjectDescriptor, true); } }
Check documentation ("Running programs in batch mode") on how to start command line.
-
-
Constructor Summary
Constructors Constructor Description CommandLine()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract byte
execute()
Override this method to execute your custom task(s) in running MagicDraw environment.void
launch(java.lang.String[] args)
Launch MagicDraw in commandline mode (without GUI).
Method starts MagicDraw application, callsexecute()
method, and shuts down the application.protected void
parseArgs(java.lang.String[] args)
Override to parse arguments before launching MagicDraw.
-
-
-
Method Detail
-
launch
public final void launch(java.lang.String[] args) throws java.lang.InstantiationException
Launch MagicDraw in commandline mode (without GUI).
Method starts MagicDraw application, callsexecute()
method, and shuts down the application.- Parameters:
args
- command line arguments passed to MagicDraw.- Throws:
java.lang.InstantiationException
- if the failed return code needs to be indicated
-
parseArgs
protected void parseArgs(java.lang.String[] args) throws java.lang.Exception
Override to parse arguments before launching MagicDraw.- Parameters:
args
- program arguments- Throws:
java.lang.Exception
- if arguments are not correct and MagicDraw should not be started
-
execute
protected abstract byte execute()
Override this method to execute your custom task(s) in running MagicDraw environment. Do not explicitly call this method - calllaunch(String[])
to launch the commandline.- Returns:
- application exit status
-
-