Merge branch '1.4.5-SNAPSHOT' into 1.5.1-SNAPSHOT Conflicts: core/src/main/java/org/apache/accumulo/core/util/shell/commands/ExecfileCommand.java
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/56230eb9 Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/56230eb9 Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/56230eb9 Branch: refs/heads/1.5.1-SNAPSHOT Commit: 56230eb9ba1252110ebcbb538576ceb0f2509799 Parents: 3b41d37 826dc48 Author: Josh Elser <josh.el...@gmail.com> Authored: Fri Jan 10 18:30:42 2014 -0500 Committer: Josh Elser <josh.el...@gmail.com> Committed: Fri Jan 10 18:30:42 2014 -0500 ---------------------------------------------------------------------- .../accumulo/core/util/shell/commands/ExecfileCommand.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/56230eb9/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ExecfileCommand.java ---------------------------------------------------------------------- diff --cc core/src/main/java/org/apache/accumulo/core/util/shell/commands/ExecfileCommand.java index dd91e2d,0000000..a9c409f mode 100644,000000..100644 --- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ExecfileCommand.java +++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ExecfileCommand.java @@@ -1,62 -1,0 +1,66 @@@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.accumulo.core.util.shell.commands; + +import java.io.File; +import java.util.Scanner; + +import org.apache.accumulo.core.util.shell.Shell; +import org.apache.accumulo.core.util.shell.Shell.Command; +import org.apache.commons.cli.CommandLine; +import org.apache.commons.cli.Option; +import org.apache.commons.cli.Options; + +public class ExecfileCommand extends Command { + private Option verboseOption; + + @Override + public String description() { + return "specifies a file containing accumulo commands to execute"; + } + + @Override + public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception { + Scanner scanner = new Scanner(new File(cl.getArgs()[0])); - while (scanner.hasNextLine()) { - shellState.execCommand(scanner.nextLine(), true, cl.hasOption(verboseOption.getOpt())); ++ try { ++ while (scanner.hasNextLine()) { ++ shellState.execCommand(scanner.nextLine(), true, cl.hasOption(verboseOption.getOpt())); ++ } ++ } finally { ++ scanner.close(); + } + return 0; + } + + @Override + public String usage() { + return getName() + " <fileName>"; + } + + @Override + public int numArgs() { + return 1; + } + + @Override + public Options getOptions() { + final Options opts = new Options(); + verboseOption = new Option("v", "verbose", false, "display command prompt as commands are executed"); + opts.addOption(verboseOption); + return opts; + } +}