Example #1
0
        public void Process()
        {
            // Set the root directory.
            string root = Directory.GetCurrentDirectory();

            // Use specified root directory.
            if (!String.IsNullOrEmpty(this.options.Root))
            {
                // Ensure provided root directory exists.
                if (!Directory.Exists(options.Root))
                {
                    this.Fatal("The specified root directory path does not exist");
                }

                // Use provided root directory path.
                root = Path.GetFullPath(this.options.Root);
            }

            // Create a new package loader instance.
            PackageLoader packageLoader = new PackageLoader(root);

            // Inform the user of the final root directory.
            Log.Verbose($"Using root directory: {root}");

            // Ensure package manifest exists.
            if (!packageLoader.DoesManifestExist)
            {
                this.Fatal("Package manifest file does not exist.");
            }

            // Load the package manifest.
            PackageDefinition package = packageLoader.ReadPackage();

            // Process package options if applicable.
            if (package.Options != null)
            {
                // Use package's root path option if applicable.
                if (package.Options.SourceRoot != null)
                {
                    // Create the new root path.
                    string newRoot = Path.GetFullPath(package.Options.SourceRoot);

                    // Ensure directory path exists.
                    if (!Directory.Exists(newRoot))
                    {
                        this.Fatal("Provided source root directory path in package manifest does not exist");
                    }

                    // Override root path.
                    root = Path.GetFullPath(package.Options.SourceRoot);

                    // Inform the user of the action taken.
                    Log.Verbose($"Using source root directory from package manifest: {root}");
                }
            }

            // Process scanner.
            this.ProcessScanner(root);
        }
Example #2
0
        public void Process()
        {
            // Retrieve operation value from options.
            string operationValue = this.options.Operation;

            // Inform the user of the requested operation if applicable.
            Log.Verbose($"Using operation: {operationValue}");

            // Resolve operation value.
            OperationType operation = Operation.Resolve(operationValue);

            // Ensure operation type is not unknown.
            if (operation == OperationType.Unknown)
            {
                Log.Error($"Unknown operation: '{operationValue}'.");
            }

            // Inform the user that the requested operation is valid, if applicable.
            Log.Verbose("Requested operation is valid.");

            // Set the operation for future use.
            this.operation = operation;

            // Set the root directory.
            string root = Directory.GetCurrentDirectory();

            // Use specified root directory.
            if (!String.IsNullOrEmpty(this.options.Root))
            {
                // Ensure provided root directory exists.
                if (!Directory.Exists(options.Root))
                {
                    Log.Error("The specified root directory path does not exist.");
                }

                // Use provided root directory path.
                root = Path.GetFullPath(this.options.Root);
            }

            // Inform the user of the final root directory.
            Log.Verbose($"Using root directory: {root}");

            // Ensure root directory exists.
            if (!Directory.Exists(root))
            {
                Log.Error("Root directory does not exist.");
            }

            // TODO: Should never modify options' root path.
            // Apply root directory to options.
            this.options.Root = root;

            // Inform the user that the root directory is valid.
            Log.Verbose("Root directory is valid.");

            // If operation is to initialize, simply initialize and finish.
            if (this.operation == OperationType.Init)
            {
                // Invoke the initialization operation handler.
                this.HandleInitOperation();

                // Terminate this function.
                return;
            }

            // Create a new package loader instance.
            PackageLoader packageLoader = new PackageLoader(root);

            // Ensure package manifest exists.
            if (!packageLoader.DoesManifestExist)
            {
                Log.Error("Package manifest file does not exist.");
            }

            // Inform the user that the package manifest exists.
            Log.Verbose("Package manifest file exists.");

            // Load the package manifest.
            Package package = packageLoader.ReadPackage();

            // Inform the user that the package manifest was loaded.
            Log.Verbose("Package manifest file loaded.");

            // Process package options if applicable.
            if (package.Options != null)
            {
                // Use package's root path option if applicable.
                if (package.Options.SourceRoot != null)
                {
                    // Create the source directory path.
                    string sourcePath = Path.GetFullPath(package.Options.SourceRoot);

                    // Inform the user of the source directory path.
                    Log.Verbose($"Using source directory: {sourcePath}");

                    // Ensure directory path exists.
                    if (!Directory.Exists(sourcePath))
                    {
                        Log.Error("Provided source root directory path in package manifest does not exist.");
                    }

                    // Inform the user that the source directory exists.
                    Log.Verbose("Source directory is valid.");

                    // Override root path.
                    root = Path.GetFullPath(package.Options.SourceRoot);

                    // Inform the user of the action taken.
                    Log.Verbose($"Using source root directory from package manifest: {root}");
                }
            }

            // Process scanner.
            Project project = this.ProcessScanner(root);

            // Summon the corresponding engine.
            this.SummonEngine(this.operation, package, project);
        }