tools/twiddle/cli/src/main/java/org/mobicents/tools/twiddle/jslee/AbstractUsageCommand.java
@Override
	protected void processArguments(String[] args) throws CommandException {

		//String sopts = "-:lgrcdni";
		String sopts = "-:lgrcdn";

		LongOpt[] lopts = {

				new LongOpt("noprefix", LongOpt.NO_ARGUMENT, null, 0x1000),
				// operration part
				new LongOpt("list", LongOpt.NO_ARGUMENT, null, 'l'),
					new LongOpt("sets", LongOpt.NO_ARGUMENT, null, ListOperation.sets),
					new LongOpt("parameters", LongOpt.NO_ARGUMENT, null, ListOperation.parameters),
				new LongOpt("get", LongOpt.NO_ARGUMENT, null, 'g'),
					new LongOpt("name", LongOpt.REQUIRED_ARGUMENT, null, GetOperation.name),
					new LongOpt("rst", LongOpt.NO_ARGUMENT, null, GetOperation.rst),
				new LongOpt("reset", LongOpt.NO_ARGUMENT, null, 'r'),
					new LongOpt("all", LongOpt.NO_ARGUMENT, null, ResetOperation.all),	
				new LongOpt("create", LongOpt.NO_ARGUMENT, null, 'c'),
				new LongOpt("delete", LongOpt.NO_ARGUMENT, null, 'd'),
				
				//mgmt
				new LongOpt("notify", LongOpt.NO_ARGUMENT, null, 'n'),
					new LongOpt("value", LongOpt.REQUIRED_ARGUMENT, null, NotifyOperation.value),
					new LongOpt("is-notify", LongOpt.NO_ARGUMENT, null, NotifyOperation.is),
		};

		Getopt getopt = new Getopt(null, args, sopts, lopts);
		getopt.setOpterr(false);
		int nonOptArgIndex = 0;
		int code;
		while ((code = getopt.getopt()) != -1) {
			switch (code) {
			case ':':
				throw new CommandException("Option requires an argument: " + args[getopt.getOptind() - 1]);

			case '?':
				throw new CommandException("Invalid (or ambiguous) option: " + args[getopt.getOptind() - 1]);

			case 0x1000:
				break;

			case 1:
				// non opt args, table and profile name(maybe)
				switch (nonOptArgIndex) {
				case 0:
					resourceName = getopt.getOptarg();
					if(resourceName.startsWith(PREFIX_SERVICEID))
					{
						
						try{
							editor.setAsText(resourceName);
						}catch(Exception e)
						{
							throw new CommandException("Command: \"" + getName() + "\" failed to parse ServiceID.",e);
						}
						this.serviceID = (ServiceID) editor.getValue();
						
						this.resourceName = null;
					}
					nonOptArgIndex++;
					break;
				case 1:
					if(this.serviceID!=null)
					{
						
						try{
							this.editor.setAsText(getopt.getOptarg());
						}catch(Exception e)
						{
							throw new CommandException("Command: \"" + getName() + "\" failed to parse SbbID.",e);
						}
						this.sbbID = (SbbID) this.editor.getValue();
					}else
					{
						usageSetName = getopt.getOptarg();
					}
					nonOptArgIndex++;
					break;
				case 2:
					if(this.serviceID == null)
					{
						throw new CommandException("Command: \"" + getName() + "\" expects at most two non opt arguments!");
					}
					usageSetName = getopt.getOptarg();
					nonOptArgIndex++;
					break;
				default:
					throw new CommandException("Command: \"" + getName() + "\" expects at most three non opt arguments!");
				}
				break;

			case 'l':
				// list
				super.operation = new ListOperation(super.context, super.log, this);
				prepareCommand();
				super.operation.buildOperation(getopt, args);
				break;
			case 'g':
				// get
				super.operation = new GetOperation(super.context, super.log, this);
				prepareCommand();
				super.operation.buildOperation(getopt, args);
				break;
			case 'r':
				// reset
				super.operation = new ResetOperation(super.context, super.log, this);
				prepareCommand();
				super.operation.buildOperation(getopt, args);
				break;
		
			case 'c':
				// create
				super.operation = new CreateOperation(super.context, super.log, this);
				prepareCommand();
				super.operation.buildOperation(getopt, args);
				break;	
			case 'd':
				// delete
				super.operation = new DeleteOperation(super.context, super.log, this);
				prepareCommand();
				super.operation.buildOperation(getopt, args);
				break;	
			case 'n':
				// notify mngr
				super.operation = new NotifyOperation(super.context, super.log, this);
				prepareCommand();
				super.operation.buildOperation(getopt, args);
				break;	
//			case 'i':
//				// check notify
//				super.operation = new IsNotifyOperation(super.context, super.log, this);
//				prepareCommand();
//				super.operation.buildOperation(getopt, args);
//				break;	
				
				
			default:
				throw new CommandException("Command: \"" + getName() + "\", found unexpected opt: " + args[getopt.getOptind() - 1]);

			}
		}
	}
@Override
	protected void processArguments(String[] args) throws CommandException {

		//String sopts = "-:lgrcdni";
		String sopts = "-:lgrcdn";

		LongOpt[] lopts = {

				new LongOpt("noprefix", LongOpt.NO_ARGUMENT, null, 0x1000),
				// operration part
				new LongOpt("list", LongOpt.NO_ARGUMENT, null, 'l'),
					new LongOpt("sets", LongOpt.NO_ARGUMENT, null, ListOperation.sets),
					new LongOpt("parameters", LongOpt.NO_ARGUMENT, null, ListOperation.parameters),
				new LongOpt("get", LongOpt.NO_ARGUMENT, null, 'g'),
					new LongOpt("name", LongOpt.REQUIRED_ARGUMENT, null, GetOperation.name),
					new LongOpt("rst", LongOpt.NO_ARGUMENT, null, GetOperation.rst),
				new LongOpt("reset", LongOpt.NO_ARGUMENT, null, 'r'),
					new LongOpt("all", LongOpt.NO_ARGUMENT, null, ResetOperation.all),	
				new LongOpt("create", LongOpt.NO_ARGUMENT, null, 'c'),
				new LongOpt("delete", LongOpt.NO_ARGUMENT, null, 'd'),
				
				//mgmt
				new LongOpt("notify", LongOpt.NO_ARGUMENT, null, 'n'),
					new LongOpt("value", LongOpt.REQUIRED_ARGUMENT, null, NotifyOperation.value),
					new LongOpt("is-notify", LongOpt.NO_ARGUMENT, null, NotifyOperation.is),
		};

		Getopt getopt = new Getopt(null, args, sopts, lopts);
		getopt.setOpterr(false);
		int nonOptArgIndex = 0;
		int code;
		while ((code = getopt.getopt()) != -1) {
			switch (code) {
			case ':':
				throw new CommandException("Option requires an argument: " + args[getopt.getOptind() - 1]);

			case '?':
				throw new CommandException("Invalid (or ambiguous) option: " + args[getopt.getOptind() - 1]);

			case 0x1000:
				break;

			case 1:
				// non opt args, table and profile name(maybe)
				switch (nonOptArgIndex) {
				case 0:
					resourceName = getopt.getOptarg();
					if(resourceName.startsWith(PREFIX_SERVICEID))
					{
						
						try{
							editor.setAsText(resourceName);
						}catch(Exception e)
						{
							throw new CommandException("Command: \"" + getName() + "\" failed to parse ServiceID.",e);
						}
						this.serviceID = (ServiceID) editor.getValue();
						
						this.resourceName = null;
					}
					nonOptArgIndex++;
					break;
				case 1:
					if(this.serviceID!=null)
					{
						
						try{
							this.editor.setAsText(getopt.getOptarg());
						}catch(Exception e)
						{
							throw new CommandException("Command: \"" + getName() + "\" failed to parse SbbID.",e);
						}
						this.sbbID = (SbbID) this.editor.getValue();
					}else
					{
						usageSetName = getopt.getOptarg();
					}
					nonOptArgIndex++;
					break;
				case 2:
					if(this.serviceID == null)
					{
						throw new CommandException("Command: \"" + getName() + "\" expects at most two non opt arguments!");
					}
					usageSetName = getopt.getOptarg();
					nonOptArgIndex++;
					break;
				default:
					throw new CommandException("Command: \"" + getName() + "\" expects at most three non opt arguments!");
				}
				break;

			case 'l':
				// list
				super.operation = new ListOperation(super.context, super.log, this);
				prepareCommand();
				super.operation.buildOperation(getopt, args);
				break;
			case 'g':
				// get
				super.operation = new GetOperation(super.context, super.log, this);
				prepareCommand();
				super.operation.buildOperation(getopt, args);
				break;
			case 'r':
				// reset
				super.operation = new ResetOperation(super.context, super.log, this);
				prepareCommand();
				super.operation.buildOperation(getopt, args);
				break;
		
			case 'c':
				// create
				super.operation = new CreateOperation(super.context, super.log, this);
				prepareCommand();
				super.operation.buildOperation(getopt, args);
				break;	
			case 'd':
				// delete
				super.operation = new DeleteOperation(super.context, super.log, this);
				prepareCommand();
				super.operation.buildOperation(getopt, args);
				break;	
			case 'n':
				// notify mngr
				super.operation = new NotifyOperation(super.context, super.log, this);
				prepareCommand();
				super.operation.buildOperation(getopt, args);
				break;	
//			case 'i':
//				// check notify
//				super.operation = new IsNotifyOperation(super.context, super.log, this);
//				prepareCommand();
//				super.operation.buildOperation(getopt, args);
//				break;	
				
				
			default:
				throw new CommandException("Command: \"" + getName() + "\", found unexpected opt: " + args[getopt.getOptind() - 1]);

			}
		}
	}
/*
(non-Javadoc)

@see
org.mobicents.tools.twiddle.AbstractSleeCommand#processArguments(java
.lang.String[])