Esempio n. 1
0
        public void SetCompression(PackageCompressionLevel level)
        {
            switch (level)
            {
            case PackageCompressionLevel.None:
                compressionLevel = CompressionLevel.NoCompression;
                break;

            case PackageCompressionLevel.Fast:
                compressionLevel = CompressionLevel.Fastest;
                break;

            case PackageCompressionLevel.Optimal:
                compressionLevel = CompressionLevel.Optimal;
                break;

            default:
                throw new CommandException($"Unexpected compression value `{level}'. Valid values are {Enum.GetNames(typeof(PackageCompressionLevel)).ReadableJoin()}.");
            }

            commandOutputProvider.Information($"Setting Zip compression level to {compressionLevel.ToString()}");
        }
Esempio n. 2
0
        public PackCommand(IOctopusFileSystem fileSystem, ICommandOutputProvider commandOutputProvider) : base(commandOutputProvider)
        {
            this.fileSystem = fileSystem;

            var common = Options.For("Advanced options");

            common.Add <string>("include=", "[Optional, Multiple] Add a file pattern to include, relative to the base path e.g. /bin/*.dll - if none are specified, defaults to **.", v => includes.Add(v), allowsMultiple: true);
            common.Add <bool>("overwrite", "[Optional] Allow an existing package file of the same ID/version to be overwritten.", v => overwrite = true);

            var zip = Options.For("Zip packages");

            zip.Add <PackageCompressionLevel>("compressionLevel=", $"[Optional] Sets the compression level of the package. Valid values are {Enum.GetNames(typeof(PackageCompressionLevel)).ReadableJoin()}. Default is {DefaultPackageCompressionLevel}.", c => packageCompressionLevel = c);

            var nuget = Options.For("NuGet packages");

            nuget.Add <string>("author=", "[Optional, Multiple] Add an author to the package metadata; defaults to the current user.", v => authors.Add(v), allowsMultiple: true);
            nuget.Add <string>("title=", "[Optional] The title of the package.", v => title = v);
            nuget.Add <string>("description=", "[Optional] A description of the package; defaults to a generic description.", v => description = v);
            nuget.Add <string>("releaseNotes=", "[Optional] Release notes for this version of the package.", v => releaseNotes = v);
            nuget.Add <string>("releaseNotesFile=", "[Optional] A file containing release notes for this version of the package.", v => releaseNotesFile = v);

            var basic = Options.For("Basic options");

            basic.Add <string>("id=", "The ID of the package; e.g. MyCompany.MyApp.", v => id = v);
            basic.Add <PackageFormat>("format=", $"Package format. Valid values are {supportedPackageFormats}. Default is {DefaultPackageFormat}, though we recommend {RecommendedPackageFormat} going forward.", fmt => packageBuilder = SelectFormat(fmt));
            basic.Add <string>("version=", "[Optional] The version of the package; must be a valid SemVer; defaults to a timestamp-based version.", v => version = string.IsNullOrWhiteSpace(v) ? null : new SemanticVersion(v));
            basic.Add <string>("outFolder=", "[Optional] The folder into which the generated NuPkg file will be written; defaults to '.'.", v => { v.CheckForIllegalPathCharacters(nameof(outFolder)); outFolder = v; });
            basic.Add <string>("basePath=", "[Optional] The root folder containing files and folders to pack; defaults to '.'.", v => { v.CheckForIllegalPathCharacters(nameof(basePath)); basePath = v; });
            basic.Add <bool>("verbose", "[Optional] verbose output.", v => verbose = true);
            basic.AddLogLevelOptions();

            packageBuilder = SelectFormat(DefaultPackageFormat);
        }
 public void SetCompression(PackageCompressionLevel level)
 {
     // does nothing
 }