File tree Expand file tree Collapse file tree 1 file changed +25
-2
lines changed
Expand file tree Collapse file tree 1 file changed +25
-2
lines changed Original file line number Diff line number Diff line change 1616 * along with this program. If not, see <https://www.gnu.org/licenses/>.
1717 */
1818
19- import { compile , loadFromFile , run , saveToFile } from "@astx/lib" ;
19+ import {
20+ compile ,
21+ generateJSCode ,
22+ loadFromFile ,
23+ run ,
24+ saveToFile ,
25+ } from "@astx/lib" ;
2026import { program } from "commander" ;
21- import { readFileSync } from "fs" ;
27+ import { readFileSync , writeFileSync } from "fs" ;
2228
2329program
2430 . version ( "1.0.0" )
@@ -55,6 +61,23 @@ program
5561 run ( program ) ;
5662 } ) ;
5763
64+ program
65+ . description (
66+ "Generate .js code from .astx files (For debugging - code is not optimized or human readable)"
67+ )
68+ . command ( "gen <input> <output>" )
69+ . action ( ( input , output ) => {
70+ console . log ( "Loading .astx file..." ) ;
71+
72+ const program = loadFromFile ( input ) ;
73+
74+ console . log ( "Generating JS Code..." ) ;
75+ const code = generateJSCode ( program ) ;
76+
77+ console . log ( "Saving to file..." ) ;
78+ writeFileSync ( output , code ) ;
79+ } ) ;
80+
5881program . showHelpAfterError ( ) ;
5982
6083program . parse ( process . argv ) ;
You can’t perform that action at this time.
0 commit comments