Updated Branches: refs/heads/master 2af17926f -> d59193083
Forgot to add the new class file. Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/d5919308 Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/d5919308 Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/d5919308 Branch: refs/heads/master Commit: d59193083481ccb800ca2c2477456736db60fe0d Parents: 2af1792 Author: Aaron McCurry <[email protected]> Authored: Mon Aug 26 08:41:25 2013 -0400 Committer: Aaron McCurry <[email protected]> Committed: Mon Aug 26 08:41:25 2013 -0400 ---------------------------------------------------------------------- .../blur/shell/CreateTableCommandHelper.java | 151 +++++++++++++++++++ 1 file changed, 151 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/d5919308/blur-shell/src/main/java/org/apache/blur/shell/CreateTableCommandHelper.java ---------------------------------------------------------------------- diff --git a/blur-shell/src/main/java/org/apache/blur/shell/CreateTableCommandHelper.java b/blur-shell/src/main/java/org/apache/blur/shell/CreateTableCommandHelper.java new file mode 100644 index 0000000..e4d675f --- /dev/null +++ b/blur-shell/src/main/java/org/apache/blur/shell/CreateTableCommandHelper.java @@ -0,0 +1,151 @@ +/** + * 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.blur.shell; + +import java.io.PrintWriter; +import java.io.Writer; + +import org.apache.commons.cli.CommandLine; +import org.apache.commons.cli.CommandLineParser; +import org.apache.commons.cli.HelpFormatter; +import org.apache.commons.cli.OptionBuilder; +import org.apache.commons.cli.Options; +import org.apache.commons.cli.ParseException; +import org.apache.commons.cli.PosixParser; + +public class CreateTableCommandHelper { + @SuppressWarnings("static-access") + public static CommandLine parse(String[] otherArgs, Writer out) { + Options options = new Options(); + options.addOption( + OptionBuilder + .withDescription("Disables the blockcache for this table. (Enabled by default)") + .create("b")); + + options.addOption( + OptionBuilder + .withDescription("Disables the table when it is created. (Enabled by default)") + .create("d")); + + options.addOption( + OptionBuilder + .withDescription("Enabled strict types on a table. (Disabled by default)") + .create("s")); + + options.addOption( + OptionBuilder + .withDescription("Enables a read only table. (Disabled by default)") + .create("r")); + + options.addOption( + OptionBuilder + .isRequired() + .hasArg() + .withArgName("tablename") + .withDescription("* The table name.") + .create("t")); + + options.addOption( + OptionBuilder + .isRequired() + .hasArg() + .withArgName("shard count") + .withDescription("* The number of shards in the table.") + .create("c")); + + options.addOption( + OptionBuilder + .hasArg() + .withArgName("uri") + .withDescription("The location of the table. (Example hdfs://namenode/blur/tables/table)") + .create("l")); + + options.addOption( + OptionBuilder + .withArgName("filetype") + .hasOptionalArgs() + .withDescription("Sets the filetypes (.tim, .tis, .doc, etc.) to be cached in the block cache. (All by default)") + .create("B")); + + options.addOption( + OptionBuilder + .withDescription("If table is not strict, disables the missing field, fieldless indexing. (Enabled by default)") + .create("mfi")); + + options.addOption( + OptionBuilder + .withArgName("field type") + .hasArg() + .withDescription("If table is not strict, sets the field type for the missing field. (text by default)") + .create("mft")); + + options.addOption( + OptionBuilder + .withArgName("name value") + .hasArgs(2) + .withDescription("If table is not strict, sets the properties for the missing field.") + .create("mfp")); + + options.addOption( + OptionBuilder + .withArgName("name value") + .hasArgs(2) + .withDescription("Sets the properties for this table descriptor.") + .create("p")); + + options.addOption( + OptionBuilder + .withArgName("column name*") + .hasArgs() + .withDescription("Sets what columns to pre cache during warmup. (By default all columns are cached)") + .create("P")); + + options.addOption( + OptionBuilder + .withArgName("classname") + .hasArg() + .withDescription("Sets the similarity class for the table. (By org.apache.blur.lucene.search.FairSimilarity is used)") + .create("S")); + + options.addOption( + OptionBuilder + .withDescription("Displays help for this command.") + .create("h")); + + CommandLineParser parser = new PosixParser(); + CommandLine cmd = null; + try { + cmd = parser.parse(options, otherArgs); + if (cmd.hasOption("h")) { + HelpFormatter formatter = new HelpFormatter(); + PrintWriter pw = new PrintWriter(out, true); + formatter.printHelp(pw, HelpFormatter.DEFAULT_WIDTH, "create", null, options, + HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, null, false); + return null; + } + } catch (ParseException e) { + HelpFormatter formatter = new HelpFormatter(); + PrintWriter pw = new PrintWriter(out, true); + formatter.printHelp(pw, HelpFormatter.DEFAULT_WIDTH, "create", null, options, + HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, null, false); + return null; + } + return cmd; + } +}
