diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-09-06 12:25:51 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-09-06 12:25:51 -0700 |
commit | cea49fdee2835c366b917125cd496ac7f0d09232 (patch) | |
tree | f2c6d8ae38aebb153007f341000535f16eaf436c /020run.cc | |
parent | e5e9f7db1c5cab6c05c9881fae1fc78259ed4143 (diff) | |
download | mu-cea49fdee2835c366b917125cd496ac7f0d09232.tar.gz |
2171 - 'main' can take ingredients from the shell
Ingredients of 'main' are always strings (type address:array:character), and are delineated from .mu files to load by a "--", e.g.: $ ./mu x.mu y.mu -- a b c Here 'main' must be defined in one of x.mu and y.mu, and will receive the ingredients "a", "b", and "c".
Diffstat (limited to '020run.cc')
-rw-r--r-- | 020run.cc | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/020run.cc b/020run.cc index b280901e..78b51c44 100644 --- a/020run.cc +++ b/020run.cc @@ -154,10 +154,16 @@ transform_all(); //: Step 2: load any .mu files provided at the commandline :(before "End Commandline Parsing") -// Loading Commandline Files if (argc > 1) { - for (int i = 1; i < argc; ++i) { - load_permanently(argv[i]); + // skip argv[0] + argv++; + argc--; + // ignore argv past '--'; that's commandline args for 'main' + while (argc > 0) { + if (string(*argv) == "--") break; + load_permanently(*argv); + argv++; + argc--; } transform_all(); if (Run_tests) Recipe.erase(Recipe_ordinal[string("main")]); @@ -171,9 +177,14 @@ if (!Run_tests) { //? Trace_file = "interactive"; //? START_TRACING_UNTIL_END_OF_SCOPE; //? Trace_stream->collect_layers.insert("app"); + run_main(argc, argv); + teardown(); +} + +:(code) +void run_main(int argc, char* argv[]) { recipe_ordinal r = Recipe_ordinal[string("main")]; if (r) run(r); - teardown(); } :(code) |