Skip to content

Commit

Permalink
option output added
Browse files Browse the repository at this point in the history
  • Loading branch information
crguezl committed Mar 19, 2024
1 parent 479955f commit 9604ef6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cast.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ program
.version(version)
.usage("[options] [filename]")
.argument("[filename]", 'file with the original code')
.option("-o, --output <filename>", "file name of the json putput program")
.option("-p, --program <JS program>", "JS program is given in the command line")
.option("-jw --whites <string>", "string ' ' Specifies the number of whites for formatting the object", ' ')
.option("-e --hide <fieldnames...>", "List of AST fields to omit", [])
Expand All @@ -31,7 +32,10 @@ program
else if (filename) {
try {
let code = fs.readFileSync(filename, "utf8");
console.log(main(code, options, filename));
if (options.output) {
fs.writeFileSync(options.output, main(code, options, filename));
}
else console.log(main(code, options, filename));
} catch (e) {
console.error(e.message);
process.exit(1);
Expand Down

0 comments on commit 9604ef6

Please sign in to comment.