winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

Program.cs (1413B)


      1 // Copyright (c) Microsoft Corporation.
      2 // Licensed under the MIT License.
      3 
      4 namespace IndexCreationTool
      5 {
      6     using Microsoft.WinGetSourceCreator;
      7     using System;
      8     using System.IO;
      9     using System.Text.Json;
     10     using System.Text.Json.Serialization;
     11     using WinGetSourceCreator.Model;
     12 
     13     class Program
     14     {
     15         private static void PrintUsage()
     16         {
     17             Console.WriteLine("Usage: IndexCreationTool.exe -f <local source input json file>");
     18         }
     19 
     20         static int Main(string[] args)
     21         {
     22             try
     23             {
     24                 string inputFile = string.Empty;
     25                 for (int i = 0; i < args.Length; i++)
     26                 {
     27                     if (args[i] == "-f" && ++i < args.Length)
     28                     {
     29                         inputFile = args[i];
     30                     }
     31                 }
     32 
     33                 if (string.IsNullOrEmpty(inputFile) || !File.Exists(inputFile))
     34                 {
     35                     PrintUsage();
     36                     throw new ArgumentException("Missing input file");
     37                 }
     38 
     39                 WinGetLocalSource.CreateFromLocalSourceFile(inputFile);
     40             }
     41             catch (Exception e)
     42             {
     43                 PrintUsage();
     44                 Console.WriteLine(e.Message);
     45                 return -1;
     46             }
     47 
     48             return 0;
     49         }
     50     }
     51 }