swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Swarm-Support] extending the standard --help message


From: Marcus G. Daniels
Subject: Re: [Swarm-Support] extending the standard --help message
Date: Wed, 05 Nov 2003 10:04:41 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.6a) Gecko/20031030

Marshall, James A R wrote:

Hi,
 my Swarm app has it's own --help message that I generate myself if the
--help option is passed at runtime, however my creation of this message has
supressed the standard Swarm --help message which is very useful. Is there a
way to integrate the two somehow, or will I just have to extend my --help
message to include all the useful stuff from the standard one?
Attached is a Java example of extending the option parsing and the help message. More of an example of phase switching than anything else I suppose..
import swarm.Globals;
import swarm.SwarmEnvironmentC;
import swarm.SwarmEnvironmentCImpl;
import swarm.SwarmEnvironmentImpl;
import swarm.defobj.Arguments;
import swarm.defobj.ArgumentsC;
import swarm.defobj.ArgumentsCImpl;
import swarm.defobj.ArgumentsImpl;
import swarm.defobj.Zone;

class MyArgumentsCImpl extends ArgumentsCImpl {
  MyArgumentsCImpl (Arguments arg) {
    super (arg);
  }
  
  public int parseKey$arg (int key, String arg) {
    if (super.parseKey$arg (key, arg) != 0) {
      if (key == (int) 'M') {
        ((MyArgumentsImpl) nextPhase).arg = arg;
      }
    }  
    return 0;
  }
}

class MyArgumentsImpl extends ArgumentsImpl {
  String arg;

  MyArgumentsImpl () {
    super ();
  }
}


public class TestArguments {
  public static void main (String args[]) {
    Zone aZone = Globals.env.globalZone;
    
    ArgumentsC argumentsC = new MyArgumentsCImpl (new MyArgumentsImpl ());
    MyArgumentsImpl arguments;

    int i, len = args.length;
    String argv[] = new String[1 + len];

    argv[0] = "TestArguments";

    for (i = 0; i < len; i++)
      argv[1 + i] = args[i];

    argumentsC.createBegin (aZone);
    argumentsC.setAppName (argv[0]);
    argumentsC.setArgc$Argv (len + 1, argv);
    argumentsC.setAppModeString ("default");
    argumentsC.setBugAddress ("address@hidden");
    argumentsC.setVersion ("0.0");
      
    argumentsC.addOption$key$arg$flags$doc$group ("myarg", (int) 'M', 
"argvalue", 0, "My Argument", 0);
    arguments = (MyArgumentsImpl) argumentsC.createEnd ();

    Globals.envC.setArguments (arguments);
    Globals.envC.createEnd ();
    
    System.out.println (arguments.arg);
  }
}

reply via email to

[Prev in Thread] Current Thread [Next in Thread]