/*
 * $Id: connect.java,v 1.1 2004/12/23 12:15:53 rampil Exp $
 * Copyright (c) 2004 LOGICAL-PARADOX.ORG
 */
package org.logical_paradox.gdrn.shell.command;

import java.io.OutputStream;

import org.logical_paradox.shell.Argument;
import org.logical_paradox.shell.Command;
import org.logical_paradox.shell.ResultCode;
import org.logical_paradox.shell.ShellEnv;
import org.logical_paradox.shell.exception.CommandExecutionException;
import org.logical_paradox.shell.exception.TerminationException;

/**
 * <pre>
 * ■connect
 * 
 * 【動作仕様】
 * 指定のDSRに接続します。
 * このコマンドの動作は、setenv DEFAULT_DSR_URI=<dsr-uri>を実行した時と同じ動作をします
 * 
 * 【書式】
 * connect <dsr-uri>
 * </pre>
 * 
 * @author satoshi akabane@logical-paradox.org
 * @version $Revision: 1.1 $
 */
public class connect implements Command {
	public static final String USAGE = "connect <dsr-uri>";
	public String usage() {
		return USAGE;
	}
	public ResultCode execute(OutputStream arg0, ShellEnv arg1, Argument arg2)
		throws CommandExecutionException, TerminationException {

		if(arg2 == null || arg2.getArguments().length == 0) {
			throw new CommandExecutionException(USAGE);
		}

		// 選択中のDSRを切り替える
		arg1.setProperty("DEFAULT_DSR_URI", arg2.getArguments()[0]);

		return new ResultCode(ResultCode.STATUS_OK);
	}

}
