Skip to content

Commit

Permalink
Merge branch 'release/0.7.1' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
nils-a committed Oct 7, 2020
2 parents 6acc421 + bfb1977 commit c0acd1b
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 1 deletion.
15 changes: 14 additions & 1 deletion demo/build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,18 @@ Task("RenameFile")
.WithRenameFile(File("CODE_OF_CONDUCT.md"), File("CODE_OF_CONDUCT.txt")));
});

Task("GH78")
.IsDependentOn("Clean")
.IsDependentOn("ZipVolumes")
.Does(() =>
{
SevenZip(m => m
.InExtractMode()
.WithArchive(output + File("volume.7z.001"))
.WithArchiveType(SwitchArchiveType.SevenZip.Volumes())
.WithOutputDirectory(output + Directory("Test01")));
});

Task("Default")
.IsDependentOn("Clean")
.IsDependentOn("ZipIt")
Expand All @@ -179,6 +191,7 @@ Task("Default")
.IsDependentOn("GetHash")
.IsDependentOn("DoBenchmark")
.IsDependentOn("ListArchiveContent")
.IsDependentOn("RenameFile");
.IsDependentOn("RenameFile")
.IsDependentOn("GH78");

RunTarget(target);
12 changes: 12 additions & 0 deletions src/Cake.7zip.Tests/Settings/Switches/SwitchArchiveTypeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ public void ArchiveType_StaticProps_works(SwitchArchiveType type, string expecte
actual.Should().Be(expected);
}

[Theory]
[ClassData(typeof(TestData))]
public void ArchiveType_StaticPropsSplit_works(SwitchArchiveType type, string expectedType)
{
var fixture = new SevenZipSettingsFixture();
var expected = "-t" + expectedType + ".split";

var actual = fixture.Parse(b => type.Volumes().BuildArguments(ref b));

actual.Should().Be(expected);
}

private class TestData : IEnumerable<object[]>
{
public IEnumerator<object[]> GetEnumerator()
Expand Down
10 changes: 10 additions & 0 deletions src/Cake.7zip/Builder/ExtractCommandBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ namespace Cake.SevenZip.Builder
/// .WithArchiveType(SwitchArchiveType.Zip)
/// .WithOutputDirectory("some/other/directory"));
/// });
///
/// Task("UnzipVolumes")
/// .Does(() =>
/// {
/// SevenZip(m => m
/// .InExtractMode()
/// .WithArchive(File("path/to/file.7z.001"))
/// .WithArchiveType(SwitchArchiveType.SevenZip.Volumes())
/// .WithOutputDirectory("some/other/directory"));
/// });
/// ]]>
/// </code>
/// </example>
Expand Down
10 changes: 10 additions & 0 deletions src/Cake.7zip/Switches/SwitchArchiveType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ private SwitchArchiveType(string type)
/// </summary>
public static SwitchArchiveType Bzip2 { get; } = new SwitchArchiveType("bzip2");

/// <summary>
/// Append ".split" to the type.
/// This is needed when extracting/testing multi-volume archives.
/// </summary>
/// <returns>A <see cref="SwitchArchiveType"/> with <c>.split</c> appended.</returns>
public SwitchArchiveType Volumes()
{
return new SwitchArchiveType(type + ".split");
}

/// <inheritdoc />
public void BuildArguments(ref ProcessArgumentBuilder builder)
{
Expand Down

0 comments on commit c0acd1b

Please sign in to comment.