/*
* Copyright (c) 2003-2012 Fred Hutchinson Cancer Research Center
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.fhcrc.cpl.viewer.commandline.modules;
import org.fhcrc.cpl.toolbox.commandline.arguments.ArgumentValidationException;
import org.fhcrc.cpl.toolbox.commandline.arguments.CommandLineArgumentDefinition;
import org.fhcrc.cpl.viewer.CommandFileRunner;
import org.fhcrc.cpl.toolbox.commandline.CommandLineModuleExecutionException;
import org.fhcrc.cpl.toolbox.commandline.CommandLineModule;
import org.apache.log4j.Logger;
import java.io.File;
/**
* Command linemodule for feature finding
*/
public class RunCommandFileCommandLineModule extends BaseViewerCommandLineModuleImpl
implements CommandLineModule
{
protected static Logger _log = Logger.getLogger(RunCommandFileCommandLineModule.class);
protected File file;
public RunCommandFileCommandLineModule()
{
init();
}
protected void init()
{
mCommandName = "runcommandfile";
mHelpMessage =
"The runcommandfile command allows you to run a command file, which contains one or more " +
"commands to be run in sequence, along with their respective argument values";
mShortDescription = "Run the commands specified in a command file";
CommandLineArgumentDefinition[] argDefs =
{
createUnnamedFileArgumentDefinition(false, "Macro file to run"),
};
addArgumentDefinitions(argDefs);
}
public void assignArgumentValues()
throws ArgumentValidationException
{
file = getFileArgumentValue(CommandLineArgumentDefinition.UNNAMED_PARAMETER_VALUE_ARGUMENT);
}
/**
* do the actual work
*/
public void execute() throws CommandLineModuleExecutionException
{
CommandFileRunner.runMacroFile(file);
}
}