Skip to content

Commit dc4fe64

Browse files
author
kana0011
committed
Add cli filename support
Signed-off-by: kana0011 <marklynoel.alvarez@synacy.com>
1 parent c198371 commit dc4fe64

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/ph/kana/csvv/CsvViewerJavaFx.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public void start(Stage primaryStage) throws Exception{
1818

1919
CsvViewerController controller = loader.<CsvViewerController>getController();
2020
controller.setApplication(this);
21+
controller.openFileCliArgs(getParameters().getUnnamed());
2122

2223
primaryStage.setTitle("kana0011/csv-viewer");
2324
primaryStage.setMinWidth(APP_WIDTH);

src/ph/kana/csvv/controller/CsvViewerController.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
import java.util.List;
1717
import java.util.Map;
1818

19+
import static javafx.scene.control.Alert.AlertType;
20+
1921
public class CsvViewerController {
2022

2123
@FXML private AnchorPane rootPane;
@@ -43,6 +45,12 @@ public void setApplication(Application application) {
4345
this.application = application;
4446
}
4547

48+
public void openFileCliArgs(List<String> args) {
49+
args.stream()
50+
.map(File::new)
51+
.forEach(this::openCsvTab);
52+
}
53+
4654
private FileChooser createFileChooser() {
4755
FileChooser fileChooser = new FileChooser();
4856
File userHome = new File(System.getProperty("user.home"));
@@ -125,7 +133,7 @@ private void openLink(String url) {
125133
}
126134

127135
private void reportError(Exception e) {
128-
Alert alert = new Alert(Alert.AlertType.ERROR);
136+
Alert alert = new Alert(AlertType.ERROR);
129137
alert.setTitle("CSV Viewer Error!");
130138
alert.setHeaderText(e.getClass().getSimpleName());
131139
alert.setContentText("Failed to open file!\nCSV format might be broken.");

0 commit comments

Comments
 (0)