lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [01/22] lucenenet git commit: Added lucene-cli + tests - a wrapper console application so we can run the various utilities and demos in .NET on the command line.
Date Tue, 11 Jul 2017 07:42:26 GMT
Repository: lucenenet
Updated Branches:
  refs/heads/master 9a8c9f203 -> e8e1b5a9c


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/9e389540/src/tools/lucene-cli/commands/index/index-upgrade/IndexUpgradeCommand.cs
----------------------------------------------------------------------
diff --git a/src/tools/lucene-cli/commands/index/index-upgrade/IndexUpgradeCommand.cs b/src/tools/lucene-cli/commands/index/index-upgrade/IndexUpgradeCommand.cs
new file mode 100644
index 0000000..f849bb5
--- /dev/null
+++ b/src/tools/lucene-cli/commands/index/index-upgrade/IndexUpgradeCommand.cs
@@ -0,0 +1,83 @@
+using Lucene.Net.Cli.CommandLine;
+using Lucene.Net.Index;
+using System.Collections.Generic;
+
+namespace Lucene.Net.Cli
+{
+    /*
+     * 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.
+     */
+
+    public class IndexUpgradeCommand : ICommand
+    {
+        public class Configuration : ConfigurationBase
+        {
+            public Configuration(CommandLineOptions options)
+            {
+                this.Main = (args) => IndexUpgrader.Main(args);
+
+                this.Name = "upgrade";
+                this.Description = FromResource("Description");
+
+                this.Arguments.Add(new IndexDirectoryArgument());
+                this.DeletePriorCommitsOption = this.Option("-d|--delete-prior-commits",
+                    FromResource("DeleteDescription"), 
+                    CommandOptionType.NoValue);
+                this.Options.Add(new VerboseOption());
+                this.Options.Add(new DirectoryTypeOption());
+                
+                this.ExtendedHelpText = FromResource("ExtendedHelpText");
+
+                this.OnExecute(() => new IndexUpgradeCommand().Run(this));
+            }
+
+            public virtual CommandOption DeletePriorCommitsOption { get; private set; }
+        }
+
+        public int Run(ConfigurationBase cmd)
+        {
+            if (!cmd.ValidateArguments(1))
+            {
+                return 1;
+            }
+
+            var args = new List<string>() { cmd.GetArgument<IndexDirectoryArgument>().Value
};
+            var input = cmd as Configuration;
+            
+            if (input.DeletePriorCommitsOption != null && input.DeletePriorCommitsOption.HasValue())
+            {
+                args.Add("-delete-prior-commits");
+            }
+
+            // get vebose option
+            var verboseOption = cmd.GetOption<VerboseOption>();
+            if (verboseOption != null && verboseOption.HasValue())
+            {
+                args.Add("-verbose");
+            }
+
+            var directoryTypeOption = cmd.GetOption<DirectoryTypeOption>();
+            if (directoryTypeOption != null && directoryTypeOption.HasValue())
+            {
+                args.Add("-dir-impl");
+                args.Add(directoryTypeOption.Value());
+            }
+
+            cmd.Main(args.ToArray());
+            return 0;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/9e389540/src/tools/lucene-cli/commands/lock/LockCommand.cs
----------------------------------------------------------------------
diff --git a/src/tools/lucene-cli/commands/lock/LockCommand.cs b/src/tools/lucene-cli/commands/lock/LockCommand.cs
new file mode 100644
index 0000000..69ed17c
--- /dev/null
+++ b/src/tools/lucene-cli/commands/lock/LockCommand.cs
@@ -0,0 +1,42 @@
+namespace Lucene.Net.Cli
+{
+    /*
+     * 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.
+     */
+
+    public class LockCommand : ICommand
+    {
+        public class Configuration : ConfigurationBase
+        {
+            public Configuration(CommandLineOptions options)
+            {
+                this.Name = "lock";
+                this.Description = FromResource("Description");
+
+                this.Commands.Add(new LockStressTestCommand.Configuration(options));
+                this.Commands.Add(new LockVerifyServerCommand.Configuration(options));
+
+                this.OnExecute(() => new LockCommand().Run(this));
+            }
+        }
+
+        public int Run(ConfigurationBase cmd)
+        {
+            cmd.ShowHelp();
+            return 1;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/9e389540/src/tools/lucene-cli/commands/lock/lock-stress-test/LockStressTestCommand.cs
----------------------------------------------------------------------
diff --git a/src/tools/lucene-cli/commands/lock/lock-stress-test/LockStressTestCommand.cs
b/src/tools/lucene-cli/commands/lock/lock-stress-test/LockStressTestCommand.cs
new file mode 100644
index 0000000..9b0f908
--- /dev/null
+++ b/src/tools/lucene-cli/commands/lock/lock-stress-test/LockStressTestCommand.cs
@@ -0,0 +1,58 @@
+using Lucene.Net.Store;
+
+namespace Lucene.Net.Cli
+{
+    /*
+     * 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.
+     */
+
+    public class LockStressTestCommand : ICommand
+    {
+        public class Configuration : ConfigurationBase
+        {
+            public Configuration(CommandLineOptions options)
+            {
+                this.Main = (args) => LockStressTest.Main(args);
+
+                this.Name = "stress-test";
+                this.Description = FromResource("Description");
+
+                this.Argument("<ID>", FromResource("IDDescription"));
+                this.Argument("<VERIFIER_HOST>", FromResource("VerifierHostDescription"));
+                this.Argument("<VERIFIER_PORT>", FromResource("VerfierPortDescription"));
+                this.Argument("<LOCK_FACTORY_TYPENAME>", FromResource("LockFactoryTypeNameDescription"));
+                this.Argument("<LOCK_DIRECTORY_NAME>", FromResource("LockFactoryNameDescription"));
+                this.Argument("<SLEEP_TIME_MS>", FromResource("SleepTimeMSDescription"));
+                this.Argument("<COUNT>", FromResource("CountDescription"));
+
+                this.ExtendedHelpText = FromResource("ExtendedHelpText");
+
+                this.OnExecute(() => new LockStressTestCommand().Run(this));
+            }
+        }
+
+        public int Run(ConfigurationBase cmd)
+        {
+            if (!cmd.ValidateArguments(7))
+            {
+                return 1;
+            }
+
+            cmd.Main(cmd.GetNonNullArguments());
+            return 0;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/9e389540/src/tools/lucene-cli/commands/lock/lock-verify-server/LockVerifyServerCommand.cs
----------------------------------------------------------------------
diff --git a/src/tools/lucene-cli/commands/lock/lock-verify-server/LockVerifyServerCommand.cs
b/src/tools/lucene-cli/commands/lock/lock-verify-server/LockVerifyServerCommand.cs
new file mode 100644
index 0000000..0095888
--- /dev/null
+++ b/src/tools/lucene-cli/commands/lock/lock-verify-server/LockVerifyServerCommand.cs
@@ -0,0 +1,51 @@
+using Lucene.Net.Store;
+
+namespace Lucene.Net.Cli
+{
+    /*
+     * 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.
+     */
+
+    public class LockVerifyServerCommand : ICommand
+    {
+        public class Configuration : ConfigurationBase
+        {
+            public Configuration(CommandLineOptions options)
+            {
+                this.Main = (args) => LockVerifyServer.Main(args);
+
+                this.Name = "verify-server";
+                this.Description = FromResource("Description");
+
+                this.Argument("<IP_HOSTNAME>", FromResource("IPHostnameDescription"));
+                this.Argument("<MAX_CLIENTS>", FromResource("MaxClientsDescription"));
+
+                this.OnExecute(() => new LockVerifyServerCommand().Run(this));
+            }
+        }
+
+        public int Run(ConfigurationBase cmd)
+        {
+            if (!cmd.ValidateArguments(2))
+            {
+                return 1;
+            }
+
+            cmd.Main(cmd.GetNonNullArguments());
+            return 0;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/9e389540/src/tools/lucene-cli/lucene-cli.xproj
----------------------------------------------------------------------
diff --git a/src/tools/lucene-cli/lucene-cli.xproj b/src/tools/lucene-cli/lucene-cli.xproj
new file mode 100644
index 0000000..b9674c1
--- /dev/null
+++ b/src/tools/lucene-cli/lucene-cli.xproj
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
+    <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
+  </PropertyGroup>
+  <Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)'
!= ''" />
+  <PropertyGroup Label="Globals">
+    <ProjectGuid>d5f3414e-e743-4dca-a50a-da3278a2ba2b</ProjectGuid>
+    <RootNamespace>Lucene.Net.Cli</RootNamespace>
+    <BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
+    <OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
+    <TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
+  </PropertyGroup>
+  <PropertyGroup>
+    <SchemaVersion>2.0</SchemaVersion>
+  </PropertyGroup>
+  <Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)'
!= ''" />
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/9e389540/src/tools/lucene-cli/options/CrossCheckTermVectorsOption.cs
----------------------------------------------------------------------
diff --git a/src/tools/lucene-cli/options/CrossCheckTermVectorsOption.cs b/src/tools/lucene-cli/options/CrossCheckTermVectorsOption.cs
new file mode 100644
index 0000000..c050b74
--- /dev/null
+++ b/src/tools/lucene-cli/options/CrossCheckTermVectorsOption.cs
@@ -0,0 +1,31 @@
+using Lucene.Net.Cli.CommandLine;
+
+namespace Lucene.Net.Cli
+{
+    /*
+     * 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.
+     */
+
+    public class CrossCheckTermVectorsOption : CommandOption
+    {
+        public CrossCheckTermVectorsOption()
+            : base("-c|--cross-check-term-vectors", CommandOptionType.NoValue)
+        {
+            Description = Resources.Strings.CrossCheckTermVectorsDescription;
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/9e389540/src/tools/lucene-cli/options/DirectoryTypeOption.cs
----------------------------------------------------------------------
diff --git a/src/tools/lucene-cli/options/DirectoryTypeOption.cs b/src/tools/lucene-cli/options/DirectoryTypeOption.cs
new file mode 100644
index 0000000..2fcdfa2
--- /dev/null
+++ b/src/tools/lucene-cli/options/DirectoryTypeOption.cs
@@ -0,0 +1,30 @@
+using Lucene.Net.Cli.CommandLine;
+
+namespace Lucene.Net.Cli
+{
+    /*
+     * 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.
+     */
+
+    public class DirectoryTypeOption : CommandOption
+    {
+        public DirectoryTypeOption()
+            : base("-dir|--directory-type <DIRECTORY_TYPE>", CommandOptionType.SingleValue)
+        {
+            Description = Resources.Strings.DirectoryTypeOptionDescription;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/9e389540/src/tools/lucene-cli/options/SegmentOption.cs
----------------------------------------------------------------------
diff --git a/src/tools/lucene-cli/options/SegmentOption.cs b/src/tools/lucene-cli/options/SegmentOption.cs
new file mode 100644
index 0000000..0f164e7
--- /dev/null
+++ b/src/tools/lucene-cli/options/SegmentOption.cs
@@ -0,0 +1,31 @@
+using Lucene.Net.Cli.CommandLine;
+
+namespace Lucene.Net.Cli
+{
+    /*
+     * 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.
+     */
+
+    public class SegmentOption : CommandOption
+    {
+        public SegmentOption(bool allowMultiple = true)
+            : base("-s|--segment <SEGMENT>", allowMultiple ? CommandOptionType.MultipleValue
: CommandOptionType.SingleValue)
+        {
+            Description = Resources.Strings.SegmentsOptionDescription + 
+                (allowMultiple ? " " + Resources.Strings.SegmentsOptionMultipleDescription
: "");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/9e389540/src/tools/lucene-cli/options/VerboseOption.cs
----------------------------------------------------------------------
diff --git a/src/tools/lucene-cli/options/VerboseOption.cs b/src/tools/lucene-cli/options/VerboseOption.cs
new file mode 100644
index 0000000..e151104
--- /dev/null
+++ b/src/tools/lucene-cli/options/VerboseOption.cs
@@ -0,0 +1,30 @@
+using Lucene.Net.Cli.CommandLine;
+
+namespace Lucene.Net.Cli
+{
+    /*
+     * 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.
+     */
+
+    public class VerboseOption : CommandOption
+    {
+        public VerboseOption()
+            : base("-v|--verbose", CommandOptionType.NoValue)
+        {
+            Description = Resources.Strings.VerboseOptionDescription;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/9e389540/src/tools/lucene-cli/project.json
----------------------------------------------------------------------
diff --git a/src/tools/lucene-cli/project.json b/src/tools/lucene-cli/project.json
new file mode 100644
index 0000000..8c64570
--- /dev/null
+++ b/src/tools/lucene-cli/project.json
@@ -0,0 +1,39 @@
+{
+  "version": "4.8.0",
+  "entryPoint": "Program",
+  "buildOptions": {
+    "emitEntryPoint": true,
+    "compile": {
+      "includeFiles": [
+        "../../CommonAssemblyInfo.cs"
+      ]
+    },
+    "embed": {
+      "include": [
+        "../../Lucene.Net.Demo/*.cs",
+        "../../Lucene.Net.Demo/Facet/*.cs"
+      ]
+    }
+  },
+
+  "dependencies": {
+    "Lucene.Net": "4.8.0",
+    "Lucene.Net.Analysis.Common": "4.8.0",
+    "Lucene.Net.Analysis.Stempel": "4.8.0",
+    "Lucene.Net.Demo": "4.8.0",
+    "Lucene.Net.Expressions": "4.8.0",
+    "Lucene.Net.Facet": "4.8.0",
+    "Lucene.Net.Misc": "4.8.0",
+    "Lucene.Net.Tests.QueryParser": "4.8.0",
+    "Microsoft.NETCore.App": {
+      "type": "platform",
+      "version": "1.0.1"
+    }
+  },
+
+  "frameworks": {
+    "netcoreapp1.0": {
+      "imports": "dnxcore50"
+    }
+  }
+}


Mime
View raw message