#2497 Fan args available as a system propery

SlimerDude Thu 3 Dec 2015

For the new Env I'm working on, I need to get hold of the target pod / script that is being executed. It then tailors the available pods to the dependencies of the target.

Currently I obtain the target by setting an environment variable in a modified fan.bat script, but I figure it'd be cleaner if Fan.java set a system property of all the args passed in.

Would you be oppose to adding something like this to Fan.java?

diff -r f0792e687074 src/sys/java/fanx/tools/Fan.java
--- a/src/sys/java/fanx/tools/Fan.java	Thu Nov 19 16:58:49 2015 -0500
+++ b/src/sys/java/fanx/tools/Fan.java	Thu Dec 03 18:43:01 2015 +0000
@@ -273,6 +273,9 @@
     {
       if (args.length == 0) { help(); return -1; }
 
+      String cmdLineArgs = new List(Sys.StrType, args).toCode();
+      System.setProperty("fan.cmdLineArgs", cmdLineArgs);
+
       // process args
       for (int i=0; i<args.length; ++i)
       {

brian Thu 3 Dec 2015

You should be able to get it from the BooEnv via sys::Env.args

SlimerDude Thu 3 Dec 2015

BooEnv?

sys::Env.args isn't quite what I'm after...

Suppose Fantom is started with:

$ fan afBedSheet myApp -p 8069

Then sys::Env.args returns [myApp, -p, 8069] whereas what I'm interested in is afBedSheet arg.

Login or Signup to reply.