コード例 #1
0
        private static int Main(string[] args)
        {
            if (args.Length == 0)
            {
                ShowUsage();
                return(1);
            }

            var command = args[0].ToLower();

            switch (command)
            {
            case "pack":
                return(PackTool.Run(args.Skip(1).ToArray()));

            case "remove":
                return(RemoveTool.Run(args.Skip(1).ToArray()));

            case "restore":
                return(RestoreTool.Run(args.Skip(1).ToArray()));

            default:
                Console.WriteLine("Wrong command: " + command);
                return(1);
            }
        }
コード例 #2
0
ファイル: RestoreTool.cs プロジェクト: mujige77/UniGet
        internal static async Task <Dictionary <string, SemVer.Version> > Process(Options options)
        {
            if (options.Remove)
            {
                var ret = RemoveTool.Process(new RemoveTool.Options
                {
                    ProjectDir = Path.GetDirectoryName(options.ProjectFile)
                });
                if (ret != 0)
                {
                    throw new InvalidOperationException($"Cannot remove package: result code={ret}");
                }
            }

            var p          = Project.Load(options.ProjectFile);
            var projectDir = Path.GetDirectoryName(options.ProjectFile);
            var outputDir  = options.OutputDirectory ?? projectDir;
            var packageMap = new Dictionary <string, SemVer.Version>();

            if (p.Dependencies == null || p.Dependencies.Any() == false)
            {
                Console.WriteLine("No dependencies.");
                return(packageMap);
            }

            var context = new ProcessContext
            {
                Options    = options,
                OutputDir  = outputDir,
                PackageMap = packageMap,
                DepQueue   = new Queue <KeyValuePair <string, Project.Dependency> >(p.Dependencies)
            };

            while (context.DepQueue.Any())
            {
                var item = context.DepQueue.Dequeue();
                await ProcessStep(item.Key, item.Value, context);
            }

            return(packageMap);
        }