File tree Expand file tree Collapse file tree 3 files changed +26
-0
lines changed
Expand file tree Collapse file tree 3 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -94,6 +94,17 @@ public static void main(String[] args) throws IOException {
9494 Sandbox .main (createOwnLangArgs (args , i + 1 ));
9595 return ;
9696
97+ case "run" :
98+ final String scriptName ;
99+ if (i + 1 < args .length ) {
100+ scriptName = args [i + 1 ];
101+ createOwnLangArgs (args , i + 2 );
102+ } else {
103+ scriptName = "listScripts" ;
104+ }
105+ run (RunOptions .script (scriptName ));
106+ return ;
107+
97108 default :
98109 if (options .programSource == null ) {
99110 options .programSource = args [i ];
@@ -124,6 +135,7 @@ private static void printUsage() {
124135 -a, --showast Show AST of program
125136 -t, --showtokens Show lexical tokens
126137 -m, --showtime Show elapsed time of parsing and execution
138+ ownlang run <scriptName>
127139 """ );
128140 }
129141
Original file line number Diff line number Diff line change 66
77public class RunOptions {
88 private static final String DEFAULT_PROGRAM = "program.own" ;
9+ private static final String RES_SCRIPTS = "/scripts/" ;
910
1011 // input
1112 String programPath ;
@@ -21,6 +22,13 @@ public class RunOptions {
2122
2223 private final InputSourceDetector inputSourceDetector = new InputSourceDetector ();
2324
25+ static RunOptions script (String name ) {
26+ final var options = new RunOptions ();
27+ options .programPath = InputSourceDetector .RESOURCE_PREFIX
28+ + RES_SCRIPTS + name .toLowerCase () + ".own" ;
29+ return options ;
30+ }
31+
2432 boolean linterEnabled () {
2533 return lintMode != null && lintMode != LinterStage .Mode .NONE ;
2634 }
Original file line number Diff line number Diff line change 1+ println "Available scripts:
2+ checkUpdate - checks updates on GitHub
3+
4+ To run a script use command:
5+ ownlang run checkUpdate
6+ "
You can’t perform that action at this time.
0 commit comments