| 1 |
/* |
| 2 |
* Copyright (C)2005-2022 Haxe Foundation |
| 3 |
* |
| 4 |
* Permission is hereby granted, free of charge, to any person obtaining a |
| 5 |
* copy of this software and associated documentation files (the "Software"), |
| 6 |
* to deal in the Software without restriction, including without limitation |
| 7 |
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 |
* and/or sell copies of the Software, and to permit persons to whom the |
| 9 |
* Software is furnished to do so, subject to the following conditions: |
| 10 |
* |
| 11 |
* The above copyright notice and this permission notice shall be included in |
| 12 |
* all copies or substantial portions of the Software. |
| 13 |
* |
| 14 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 15 |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 17 |
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 18 |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 19 |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 20 |
* DEALINGS IN THE SOFTWARE. |
| 21 |
*/ |
| 22 |
exception Done; |
| 23 |
|
| 24 |
function erase_argument() { |
| 25 |
neko "$loader.args = $asub($loader.args,1,$asize($loader.args)-1)" |
| 26 |
} |
| 27 |
|
| 28 |
function invalid_arg(f) { |
| 29 |
throw Args.Invalid |
| 30 |
} |
| 31 |
|
| 32 |
try { |
| 33 |
var year : int = neko "$neko_build_year()"; |
| 34 |
var head = "Neko Tools v1.0 - (c)2005-" + year + " Haxe Foundation\nUsage : nekotools [options]"; |
| 35 |
var decl = [ |
| 36 |
("server", Args.Void (function() { |
| 37 |
erase_argument(); |
| 38 |
WebServer.init(); |
| 39 |
throw Done |
| 40 |
}) , " : start a neko web server"); |
| 41 |
("boot", Args.String (function(_) { |
| 42 |
// separated from boot -c only for help message |
| 43 |
}) , "<file.n> : build a standalone executable"); |
| 44 |
("boot", Args.String (function(_) { |
| 45 |
erase_argument(); |
| 46 |
neko "$loader.loadmodule('tools/nekoboot',$loader)"; |
| 47 |
throw Done; |
| 48 |
}) , "-c <file.n> : build a standalone c program"); |
| 49 |
]; |
| 50 |
Args.parse head decl invalid_arg; |
| 51 |
} catch { |
| 52 |
| e -> |
| 53 |
if e == Done then Sys.exit(0); |
| 54 |
Stack.dump IO.stderr Stack.exc(); |
| 55 |
IO.printf IO.stderr "Exception : %s\n" string(e); |
| 56 |
Sys.exit (-1); |
| 57 |
} |