Ejemplo n.º 1
0
        static int Main(string[] args)
        {
            var command = new RootCommand
            {
                new Option <FileInfo>("--out-file")
                {
                    Description = "Location to write the generated interface file",
                    IsRequired  = true
                }.ExistingOnly()
            };

            command.Handler = CommandHandler.Create((FileInfo outFile) =>
            {
                var generated = InterfaceGenerator.Generate();
                File.WriteAllText(outFile.FullName, generated);
            });
            return(command.Invoke(args));
        }
Ejemplo n.º 2
0
        static int Main(string[] args)
        {
            var existingOnlyOption = new Option <FileInfo>("--out-file")
            {
                Description = "Location to write the generated interface file",
                IsRequired  = true
            }.ExistingOnly();

            var command = new RootCommand
            {
                existingOnlyOption
            };

            command.SetHandler(async(FileInfo f) =>
            {
                var generated = InterfaceGenerator.Generate();
                await File.WriteAllTextAsync(f.FullName, generated);
            }, existingOnlyOption);

            return(command.Invoke(args));
        }