internal virtual void AddOption(string longName, bool required, string description , string paramName) { Option option = OptionBuilder.Create(longName); options.AddOption(option); }
private static Options BuildCliOptions() { Options opts = new Options(); Option file = OptionBuilder.Create("f"); Option paths = OptionBuilder.Create("p"); OptionGroup group = new OptionGroup(); group.AddOption(file); group.AddOption(paths); opts.AddOptionGroup(group); return(opts); }
internal CommandLineOpts() { geteditsizeOpt = new Option("geteditsize", "return the number of uncheckpointed transactions on the NameNode" ); checkpointOpt = OptionBuilder.Create("checkpoint"); formatOpt = new Option("format", "format the local storage during startup"); helpOpt = new Option("h", "help", false, "get help information"); options.AddOption(geteditsizeOpt); options.AddOption(checkpointOpt); options.AddOption(formatOpt); options.AddOption(helpOpt); }
private Options BuildOptions() { Options opts = new Options(); opts.AddOption(OptionBuilder.Create("s")); opts.AddOption(OptionBuilder.Create("r")); opts.AddOption(OptionBuilder.Create("c")); opts.AddOption(OptionBuilder.Create("m")); opts.AddOption(OptionBuilder.Create("t")); opts.AddOption(OptionBuilder.Create("p")); opts.AddOption(OptionBuilder.Create('h')); opts.AddOption(OptionBuilder.Create('e')); opts.AddOption(OptionBuilder.Create('?')); return(opts); }
/// <summary>Test that options passed to the constructor are used.</summary> /// <exception cref="System.Exception"/> public virtual void TestCreateWithOptions() { // Create new option newOpt Option opt = OptionBuilder.Create("newOpt"); Options opts = new Options(); opts.AddOption(opt); // Check newOpt is actually used to parse the args string[] args = new string[2]; args[0] = "--newOpt"; args[1] = "7"; GenericOptionsParser g = new GenericOptionsParser(opts, args); Assert.Equal("New option was ignored", "7", g.GetCommandLine() .GetOptionValues("newOpt")[0]); }
/// <summary>parse args</summary> /// <exception cref="System.ArgumentException"/> private static CommandLine ParseArgs(Options opts, params string[] args) { OptionBuilder.WithArgName("NameNode|DataNode"); OptionBuilder.HasArg(); OptionBuilder.WithDescription("specify jmx service (NameNode by default)"); Option jmx_service = OptionBuilder.Create("service"); OptionBuilder.WithArgName("mbean server"); OptionBuilder.HasArg(); OptionBuilder.WithDescription("specify mbean server (localhost by default)"); Option jmx_server = OptionBuilder.Create("server"); OptionBuilder.WithDescription("print help"); Option jmx_help = OptionBuilder.Create("help"); OptionBuilder.WithArgName("mbean server port"); OptionBuilder.HasArg(); OptionBuilder.WithDescription("specify mbean server port, " + "if missing - it will try to connect to MBean Server in the same VM" ); Option jmx_port = OptionBuilder.Create("port"); OptionBuilder.WithArgName("VM's connector url"); OptionBuilder.HasArg(); OptionBuilder.WithDescription("connect to the VM on the same machine;" + "\n use:\n jstat -J-Djstat.showUnsupported=true -snap <vmpid> | " + "grep sun.management.JMXConnectorServer.address\n " + "to find the url"); Option jmx_localVM = OptionBuilder.Create("localVM"); opts.AddOption(jmx_server); opts.AddOption(jmx_help); opts.AddOption(jmx_service); opts.AddOption(jmx_port); opts.AddOption(jmx_localVM); CommandLine commandLine = null; CommandLineParser parser = new GnuParser(); try { commandLine = parser.Parse(opts, args, true); } catch (ParseException e) { PrintUsage(opts); throw new ArgumentException("invalid args: " + e.Message); } return(commandLine); }
/// <summary>Build command-line options and descriptions</summary> private static Options BuildOptions() { Options options = new Options(); // Build in/output file arguments, which are required, but there is no // addOption method that can specify this OptionBuilder.IsRequired(); OptionBuilder.HasArgs(); OptionBuilder.WithLongOpt("inputFile"); options.AddOption(OptionBuilder.Create("i")); options.AddOption("o", "outputFile", true, string.Empty); options.AddOption("p", "processor", true, string.Empty); options.AddOption("h", "help", false, string.Empty); options.AddOption("maxSize", true, string.Empty); options.AddOption("step", true, string.Empty); options.AddOption("addr", true, string.Empty); options.AddOption("delimiter", true, string.Empty); options.AddOption("t", "temp", true, string.Empty); return(options); }
public virtual int Rm(string[] args) { Option recursive = OptionBuilder.Create("r"); Options rmOption = new Options(); rmOption.AddOption(recursive); bool recursiveOpt = false; CommandLineParser parser = new GnuParser(); try { CommandLine line = parser.Parse(rmOption, args); IList <string> argsList = line.GetArgList(); if (argsList.Count != 2) { return(UsageError("RM requires exactly one path argument", RmUsage)); } if (!ValidatePath(argsList[1])) { return(-1); } try { if (line.HasOption("r")) { recursiveOpt = true; } registry.Delete(argsList[1], recursiveOpt); return(0); } catch (Exception e) { syserr.WriteLine(AnalyzeException("rm", e, argsList)); } return(-1); } catch (ParseException exp) { return(UsageError("Invalid syntax " + exp.ToString(), RmUsage)); } }
/// <summary>Build command-line options and descriptions</summary> /// <returns>command line options</returns> public static Options BuildOptions() { Options options = new Options(); // Build in/output file arguments, which are required, but there is no // addOption method that can specify this OptionBuilder.IsRequired(); OptionBuilder.HasArgs(); OptionBuilder.WithLongOpt("outputFilename"); options.AddOption(OptionBuilder.Create("o")); OptionBuilder.IsRequired(); OptionBuilder.HasArgs(); OptionBuilder.WithLongOpt("inputFilename"); options.AddOption(OptionBuilder.Create("i")); options.AddOption("p", "processor", true, string.Empty); options.AddOption("v", "verbose", false, string.Empty); options.AddOption("f", "fix-txids", false, string.Empty); options.AddOption("r", "recover", false, string.Empty); options.AddOption("h", "help", false, string.Empty); return(options); }
private Options BuildOptions() { Option compress = OptionBuilder.Create('c'); Option fileSize = OptionBuilder.Create('s'); Option fsInputBufferSz = OptionBuilder.Create('i'); Option fsOutputBufferSize = OptionBuilder.Create('o'); Option keyLen = OptionBuilder.Create('k'); Option valueLen = OptionBuilder.Create('v'); Option blockSz = OptionBuilder.Create('b'); Option seed = OptionBuilder.Create('S'); Option operation = OptionBuilder.Create('x'); Option rootDir = OptionBuilder.Create('r'); Option file = OptionBuilder.Create('f'); Option seekCount = OptionBuilder.Create('n'); Option help = OptionBuilder.Create("h"); return(new Options().AddOption(compress).AddOption(fileSize).AddOption(fsInputBufferSz ).AddOption(fsOutputBufferSize).AddOption(keyLen).AddOption(blockSz).AddOption(rootDir ).AddOption(valueLen).AddOption(operation).AddOption(seekCount).AddOption(file). AddOption(help)); }
/// <summary>Specify properties of each generic option</summary> private static Options BuildGeneralOptions(Options opts) { Option fs = OptionBuilder.Create("fs"); Option jt = OptionBuilder.Create("jt"); Option oconf = OptionBuilder.Create("conf"); Option property = OptionBuilder.Create('D'); Option libjars = OptionBuilder.Create("libjars"); Option files = OptionBuilder.Create("files"); Option archives = OptionBuilder.Create("archives"); // file with security tokens Option tokensFile = OptionBuilder.Create("tokenCacheFile"); opts.AddOption(fs); opts.AddOption(jt); opts.AddOption(oconf); opts.AddOption(property); opts.AddOption(libjars); opts.AddOption(files); opts.AddOption(archives); opts.AddOption(tokensFile); return(opts); }
/// <summary>Creates configuration options object.</summary> private Options MakeOptions() { Options options = new Options(); options.AddOption("datanodes", true, "How many datanodes to start (default 1)").AddOption ("format", false, "Format the DFS (default false)").AddOption("cmdport", true, "Which port to listen on for commands (default 0--we choose)" ).AddOption("nnport", true, "NameNode port (default 0--we choose)").AddOption("namenode" , true, "URL of the namenode (default " + "is either the DFS cluster or a temporary dir)" ).AddOption(OptionBuilder.Create("D")).AddOption(OptionBuilder.Create("writeConfig" )).AddOption(OptionBuilder.Create("writeDetails")).AddOption(OptionBuilder.Create ("help")); return(options); }
/// <summary>Creates configuration options object.</summary> private Options MakeOptions() { Options options = new Options(); options.AddOption("nodfs", false, "Don't start a mini DFS cluster").AddOption("nomr" , false, "Don't start a mini MR cluster").AddOption("nodemanagers", true, "How many nodemanagers to start (default 1)" ).AddOption("datanodes", true, "How many datanodes to start (default 1)").AddOption ("format", false, "Format the DFS (default false)").AddOption("nnport", true, "NameNode port (default 0--we choose)" ).AddOption("namenode", true, "URL of the namenode (default " + "is either the DFS cluster or a temporary dir)" ).AddOption("rmport", true, "ResourceManager port (default 0--we choose)").AddOption ("jhsport", true, "JobHistoryServer port (default 0--we choose)").AddOption(OptionBuilder .Create("D")).AddOption(OptionBuilder.Create("writeConfig")).AddOption(OptionBuilder .Create("writeDetails")).AddOption(OptionBuilder.Create("help")); return(options); }
public virtual int Bind(string[] args) { Option rest = OptionBuilder.Create("rest"); Option webui = OptionBuilder.Create("webui"); Option inet = OptionBuilder.Create("inet"); Option port = OptionBuilder.Create("p"); Option host = OptionBuilder.Create("h"); Option apiOpt = OptionBuilder.Create("api"); Options inetOption = new Options(); inetOption.AddOption(inet); inetOption.AddOption(port); inetOption.AddOption(host); inetOption.AddOption(apiOpt); Options webuiOpt = new Options(); webuiOpt.AddOption(webui); webuiOpt.AddOption(apiOpt); Options restOpt = new Options(); restOpt.AddOption(rest); restOpt.AddOption(apiOpt); CommandLineParser parser = new GnuParser(); ServiceRecord sr = new ServiceRecord(); CommandLine line; if (args.Length <= 1) { return(UsageError("Invalid syntax ", BindUsage)); } if (args[1].Equals("-inet")) { int portNum; string hostName; string api; try { line = parser.Parse(inetOption, args); } catch (ParseException exp) { return(UsageError("Invalid syntax " + exp.Message, BindUsage)); } if (line.HasOption("inet") && line.HasOption("p") && line.HasOption("h") && line. HasOption("api")) { try { portNum = System.Convert.ToInt32(line.GetOptionValue("p")); } catch (FormatException exp) { return(UsageError("Invalid Port - int required" + exp.Message, BindUsage)); } hostName = line.GetOptionValue("h"); api = line.GetOptionValue("api"); sr.AddExternalEndpoint(RegistryTypeUtils.InetAddrEndpoint(api, ProtocolTypes.ProtocolHadoopIpc , hostName, portNum)); } else { return(UsageError("Missing options: must have host, port and api", BindUsage)); } } else { if (args[1].Equals("-webui")) { try { line = parser.Parse(webuiOpt, args); } catch (ParseException exp) { return(UsageError("Invalid syntax " + exp.Message, BindUsage)); } if (line.HasOption("webui") && line.HasOption("api")) { URI theUri; try { theUri = new URI(line.GetOptionValue("webui")); } catch (URISyntaxException e) { return(UsageError("Invalid URI: " + e.Message, BindUsage)); } sr.AddExternalEndpoint(RegistryTypeUtils.WebEndpoint(line.GetOptionValue("api"), theUri)); } else { return(UsageError("Missing options: must have value for uri and api", BindUsage)); } } else { if (args[1].Equals("-rest")) { try { line = parser.Parse(restOpt, args); } catch (ParseException exp) { return(UsageError("Invalid syntax " + exp.Message, BindUsage)); } if (line.HasOption("rest") && line.HasOption("api")) { URI theUri = null; try { theUri = new URI(line.GetOptionValue("rest")); } catch (URISyntaxException e) { return(UsageError("Invalid URI: " + e.Message, BindUsage)); } sr.AddExternalEndpoint(RegistryTypeUtils.RestEndpoint(line.GetOptionValue("api"), theUri)); } else { return(UsageError("Missing options: must have value for uri and api", BindUsage)); } } else { return(UsageError("Invalid syntax", BindUsage)); } } } IList <string> argsList = line.GetArgList(); if (argsList.Count != 2) { return(UsageError("bind requires exactly one path argument", BindUsage)); } if (!ValidatePath(argsList[1])) { return(-1); } try { registry.Bind(argsList[1], sr, BindFlags.Overwrite); return(0); } catch (Exception e) { syserr.WriteLine(AnalyzeException("bind", e, argsList)); } return(-1); }
internal virtual void AddArgument(string name, bool required, string description) { Option option = OptionBuilder.Create(); options.AddOption(option); }