Beispiel #1
0
        private static void PrintUsage(string command, string description, IList <CommandOption> options, string arguments)
        {
            const int INDENT = 3;

            Console.WriteLine($"{command}: ");
            Console.WriteLine($"{new string(' ', INDENT)}{description}");
            Console.WriteLine("\t");


            if (!string.IsNullOrEmpty(arguments))
            {
                Console.WriteLine($"{new string(' ', INDENT)}dotnet lambda {command} [arguments] [options]");
                Console.WriteLine($"{new string(' ', INDENT)}Arguments:");
                Console.WriteLine($"{new string(' ', INDENT * 2)}{arguments}");
            }
            else
            {
                Console.WriteLine($"{new string(' ', INDENT)}dotnet lambda {command} [options]");
            }

            var defaults = LambdaToolsDefaultsReader.LoadDefaults(Directory.GetCurrentDirectory(), LambdaToolsDefaultsReader.DEFAULT_FILE_NAME);

            const int SWITCH_COLUMN_WIDTH = 40;

            Console.WriteLine($"{new string(' ', INDENT)}Options:");
            foreach (var option in options)
            {
                StringBuilder sb = new StringBuilder();
                if (option.ShortSwitch != null)
                {
                    sb.Append($"{option.ShortSwitch.PadRight(6)} | ");
                }

                sb.Append($"{option.Switch}");
                if (sb.Length < SWITCH_COLUMN_WIDTH)
                {
                    sb.Append(new string(' ', SWITCH_COLUMN_WIDTH - sb.Length));
                }

                sb.Append(option.Description);
                var optionDefault = defaults.GetValueAsString(option);
                if (optionDefault != null)
                {
                    sb.Append($" (Default Value: {optionDefault})");
                }

                Console.WriteLine($"{new string(' ', INDENT * 2)}{sb.ToString()}");
            }
        }
Beispiel #2
0
        private void FlattenKnownPlatformDependencies(string projectLocation, string publishLocation)
        {
            var listOfDependencies = KNOWN_PLATFORM_DEPENDENCIES;


            var defaults         = LambdaToolsDefaultsReader.LoadDefaults(projectLocation);
            var extraDependences = defaults["additional-files"] as string[];

            if (extraDependences != null)
            {
                foreach (var item in extraDependences)
                {
                    listOfDependencies.Add(item);
                }
            }

            foreach (var relativePath in listOfDependencies)
            {
                var    fileName = Path.GetFileName(relativePath);
                string source;
                if (Path.IsPathRooted(relativePath))
                {
                    source = relativePath;
                }
                else
                {
                    source = Path.Combine(publishLocation, relativePath);
                }
                var target = Path.Combine(publishLocation, fileName);
                if (File.Exists(source) && !File.Exists(target))
                {
                    File.Copy(source, target);
                    _logger?.WriteLine($"... publish: Adding additional file {relativePath}");
                }
            }
        }