Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass file at command line#46 #48

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/main/java/org/markdownwriterfx/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
import org.markdownwriterfx.util.ActionUtils;
import org.markdownwriterfx.util.Utils;
import static de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon.*;
import java.io.File;

/**
* Main window containing a tab pane in the center for file editors.
Expand Down Expand Up @@ -620,4 +621,14 @@ private void helpAbout() {

alert.showAndWait();
}

/**
* Opens the given file in the editor.
* @param file
*/
public void openEditor(File file) {
fileEditorManager.openEditor(file);
}

}

13 changes: 13 additions & 0 deletions src/main/java/org/markdownwriterfx/MarkdownWriterFXApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
import fr.brouillard.oss.cssfx.api.URIToPathConverter;
import org.markdownwriterfx.options.Options;
import org.markdownwriterfx.util.StageState;
import java.util.List;
import java.io.File;

/**
* Markdown Writer FX application.
Expand Down Expand Up @@ -89,6 +91,17 @@ public Path convert(String uri) {
primaryStage.setTitle("Markdown Writer FX");
primaryStage.setScene(mainWindow.getScene());
primaryStage.show();
//open file at command line
Parameters params = getParameters();
List<String> list = params.getRaw();

// Check If File is passed from commandline
if (list.size() == 1) {
File file = new File(list.get(0));
if(file.exists()) {
mainWindow.openEditor(file);
}
}
}

public static void showDocument(String uri) {
Expand Down