forked from common-workflow-language/cwljava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommandLineToolDemo.java
More file actions
43 lines (30 loc) · 1.2 KB
/
Copy pathCommandLineToolDemo.java
File metadata and controls
43 lines (30 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Compile: ./compile-demo.sh wc-tool.cwl wc-job.json
//
// Run: ./run-demo.sh wc-tool.cwl wc-job.json
import java.util.*;
import org.commonwl.lang.*;
import org.commonwl.util.*;
public class CommandLineToolDemo {
public static void main( String [] args ) throws Exception {
//CWLReader tool = new CWLReader("wc-tool.cwl");
CWLReader tool = new CWLReader( args[0] );
tool.processFile();
CommandLineTool CommandLineTool_Instance = tool.getCommandLineToolInstance();
//JSONReader job = new JSONReader("wc-job.json");
JSONReader job = new JSONReader( args[1] );
job.processFile();
// Execute the job
SystemCommandExecution engine = new SystemCommandExecution();
// Initialize a new command to execute
engine.newExecutionCommand();
// Prepare the command to execute
engine.extendExecutionCommand( CommandLineTool_Instance.getbaseCommand() );
String stdinPath = (String) CommandLineTool_Instance.getstdin();
stdinPath = stdinPath.replace( "inputs.", "" );
engine.extendExecutionCommand( job.getValue( stdinPath ) );
// Execute the command
engine.executeCommand();
// Return the result
System.out.println( engine.getStandardOutput() );
}
}