Skip to content
This repository was archived by the owner on May 9, 2024. It is now read-only.

Commit 699ead5

Browse files
committed
Added --out and -o options
1 parent 4006ddd commit 699ead5

2 files changed

Lines changed: 30 additions & 4 deletions

File tree

compiled/README.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
Compiled files after compilation will go here.
1+
This is the standard compiler's output directory.
2+
If --out or -o option wasn't given to the compiler, the compiled files after compilation will go here.

helper.js

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ le._apps.py93 = {
2121
this.arg.command == "py93 c help" ||
2222
this.arg.command == "py93 c h"
2323
) {
24-
$log('Py93 Menu: py93compile: usage:\npy93 [compile or c] [?help or h] [filepath] [?--name NAME] [--packages-ignore or -pi]\n===========================================================\nUse "help" or "h" to see this help message.\nfilepath - path to .py file that needs to be compiled\n--name NAME - output file name.\nExample: "py93 c /a/w93.py --name windows93" => file w93.py in /a/ has been compiled and saved as windows93.html.\n(If there\'s no --name option, the target file name will be the same as the source.)\n--packages-ignore or -pi - use these options if don\'t want to load packages from "packages" folder in the compiled file.\nWorking command example: py93 c /a/w93.py --name windows93');
24+
$log('Py93 Menu: py93compile: usage:\npy93 [compile or c] [help or h] [filepath] [--name NAME] [--packages-ignore or -pi] [-o or --out OUTDIR]\n===========================================================\nUse "help" or "h" to see this help message.\nfilepath - path to .py file that needs to be compiled\n--name NAME - output file name.\nExample: "py93 c /a/w93.py --name windows93" => file w93.py in /a/ has been compiled and saved as windows93.html.\n(If there\'s no --name option, the target file name will be the same as the source.)\n--packages-ignore or -pi - use these options if don\'t want to load packages from "packages" folder in the compiled file.\n-o or --out OUTDIR - use these options to set the output directory.\n(If there\'s no --out or -o option, the standard output directory will be used (/a/Py93/compiled/))\nWorking command example: py93 c /a/w93.py --name windows93 -pi --out a/desktop');
2525
} else {
2626
let attrs = this.arg.command.split(' ');
2727
var compFile;
@@ -52,7 +52,9 @@ le._apps.py93 = {
5252
}
5353
$db.getRaw(compFile, dbCallback);
5454
var name = null;
55-
var packages = {}
55+
var packages = {};
56+
var stdoutdir = /*'/a/*/'Py93/compiled/';
57+
var outdir = /*'/a/*/'Py93/compiled/';
5658
packages.ignore = false
5759
attrs.forEach((attr) => {
5860
if (attr == '--name') {
@@ -62,6 +64,28 @@ le._apps.py93 = {
6264
} else if (attr == '--packages-ignore' || attr == '-pi') {
6365
$log(`Detected ${attr} option`)
6466
packages.ignore = true
67+
} else if (attr == '--out' || attr == '-o') {
68+
$log(`Detected ${attr} option`)
69+
let outid = attrs.indexOf(`${attr}`)
70+
let wrong = false;
71+
outdir = attrs[outid + 1]
72+
// doing some validation
73+
if (outdir[0] == "/") outdir = outdir.substr(1) // a/path/
74+
if (outdir[0] != "a") {
75+
wrong = true;
76+
if (outdir[0] == "c") $log.red('py93compile: compiler error: can\'t write to /c/, using standard output directory.');
77+
else $log.red('py93compile: compiler error: wrong output directory, using standard output directory.');
78+
} else {
79+
outdir = outdir.substr(1) // /path/
80+
}
81+
if (!wrong) {
82+
outdir = outdir.substr(1) // path/
83+
if ('/' != outdir.slice(-1)) { // path => path/
84+
outdir += '/';
85+
}
86+
} else {
87+
outdir = stdoutdir;
88+
}
6589
}
6690
});
6791
/**
@@ -119,7 +143,8 @@ le._apps.py93 = {
119143
filename = $fs.utils.getName(compFile);
120144
filename = $fs.utils.replaceExt(filename, "html");
121145
}
122-
var compNameFin = 'Py93/compiled/'+filename;
146+
var compNameFin = outdir + filename;
147+
//$log(compNameFin)
123148
$db.set(compNameFin, htmlfile);
124149
$log.green('Finished compilation.\nCompiled file path: /a/' + compNameFin + '\nWrite "$explorer.refresh();" to the terminal to make compiled file visible.'); // FIXME: Need to fix a bug when using $explorer.refresh() in the script does nothing
125150
}

0 commit comments

Comments
 (0)