1234567891011121314151617181920212223242526 |
- using System;
- using System.Linq;
- using ArcToolkitCLI.Commands.Converters;
- using CommandLine;
- namespace ArcToolkitCLI.Commands
- {
- [Verb("convert", HelpText = "Convert between common data types")]
- public class ConvertCommand : ICommand
- {
- public int Run()
- {
- var commandTypes = typeof(ConvertCommand).Assembly.GetTypes()
- .Where(t => !t.IsInterface && !t.IsAbstract && t != typeof(BaseConverter) &&
- typeof(BaseConverter).IsAssignableFrom(t))
- .ToArray();
- return new Parser(with =>
- {
- with.IgnoreUnknownArguments = true;
- with.HelpWriter = Parser.Default.Settings.HelpWriter;
- }).ParseArguments(Environment.GetCommandLineArgs().Skip(2), commandTypes)
- .MapResult((object t) => ((BaseConverter)t).Run(), errs => 1);
- }
- }
- }
|