Beispiel #1
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        private static async Task Main(string[] args)
        {
            var options = new CLIOptions();

            Parser.Default.ParseArguments <CLIOptions>(args)
            .WithParsed(r => options = r);

            if (options.RunBatchProcessing)
            {
                if (string.IsNullOrEmpty(options.TargetDirectory) || options.ManifestType == EManifestType.Unknown)
                {
                    Log.Error("Target directory not set, or manifest type not set.");
                    return;
                }

                // At this point, the options should be valid. Run batch processing.
                if (Directory.Exists(options.TargetDirectory))
                {
                    Log.Info("Generating manifest...");

                    var manifestGenerationHandler = new ManifestGenerationHandler();

                    var progressReporter = new Progress <ManifestGenerationProgressChangedEventArgs>
                                           (
                        e => Log.Info($"Processed file {e.Filepath} : {e.Hash} : {e.Filesize}")
                                           );

                    await manifestGenerationHandler.GenerateManifestAsync
                    (
                        options.TargetDirectory,
                        options.ManifestType,
                        progressReporter,
                        CancellationToken.None
                    );

                    Log.Info("Generation finished.");
                }
                else
                {
                    Log.Error("The selected directory did not exist.");
                }
            }
            else if (string.IsNullOrEmpty(options.TargetDirectory) && options.ManifestType == EManifestType.Unknown)
            {
                // Run a GTK UI instead of batch processing
                Application.Init();
                SynchronizationContext.SetSynchronizationContext(new GLibSynchronizationContext());

                var win = MainWindow.Create();
                win.Show();
                Application.Run();
            }
        }
Beispiel #2
0
        private static void Main(string[] args)
        {
            CLIOptions options = new CLIOptions();

            if (CommandLine.Parser.Default.ParseArguments(args, options))
            {
                if (options.RunBatchProcessing)
                {
                    if (string.IsNullOrEmpty(options.TargetDirectory) || options.ManifestType == EManifestType.Unknown)
                    {
                        Console.Write(options.GetUsage());
                    }

                    // At this point, the options should be valid. Run batch processing.
                    if (Directory.Exists(options.TargetDirectory))
                    {
                        Log.Info("Generating manifest...");

                        ManifestGenerationHandler manifestGenerationHandler = new ManifestGenerationHandler();

                        manifestGenerationHandler.ManifestGenerationProgressChanged += OnProgressChanged;
                        manifestGenerationHandler.ManifestGenerationFinished        += OnGenerationFinished;

                        manifestGenerationHandler.GenerateManifest(options.TargetDirectory, options.ManifestType);
                    }
                    else
                    {
                        Log.Error("The selected directory did not exist.");
                    }
                }
                else if (string.IsNullOrEmpty(options.TargetDirectory) && options.ManifestType == EManifestType.Unknown)
                {
                    // Run a GTK UI instead of batch processing
                    Application.Init();

                    MainWindow win = new MainWindow();
                    win.Show();
                    Application.Run();
                }
                else
                {
                    Console.Write(options.GetUsage());
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        private static async Task Main(string[] args)
        {
            // Set correct working directory for compatibility with double-clicking
            Directory.SetCurrentDirectory(DirectoryHelpers.GetLocalDir());

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                Environment.SetEnvironmentVariable("GSETTINGS_SCHEMA_DIR", "share\\glib-2.0\\schemas\\");
            }

            var options = new CLIOptions();

            Parser.Default.ParseArguments <CLIOptions>(args)
            .WithParsed(r => options    = r)
            .WithNotParsed(r => options = null);

            if (options is null)
            {
                // Parsing probably failed, bail out
                return;
            }

            if (options.RunBatchProcessing)
            {
                if (string.IsNullOrEmpty(options.TargetDirectory) || options.ManifestType == EManifestType.Unknown)
                {
                    Log.Error("Target directory not set, or manifest type not set.");
                    return;
                }

                // At this point, the options should be valid. Run batch processing.
                if (Directory.Exists(options.TargetDirectory))
                {
                    Log.Info("Generating manifest...");

                    var manifestGenerationHandler = new ManifestGenerationHandler();

                    var progressReporter = new Progress <ManifestGenerationProgressChangedEventArgs>
                                           (
                        e => Log.Info($"Processed file {e.Filepath} : {e.Hash} : {e.Filesize}")
                                           );

                    await manifestGenerationHandler.GenerateManifestAsync
                    (
                        options.TargetDirectory,
                        options.ManifestType,
                        progressReporter,
                        CancellationToken.None
                    );

                    Log.Info("Generation finished.");
                }
                else
                {
                    Log.Error("The selected directory did not exist.");
                }
            }
            else if (string.IsNullOrEmpty(options.TargetDirectory) && options.ManifestType == EManifestType.Unknown)
            {
                // Run a GTK UI instead of batch processing
                Application.Init();
                SynchronizationContext.SetSynchronizationContext(new GLibSynchronizationContext());

                var win = MainWindow.Create();
                win.Show();
                Application.Run();
            }
        }