-
Notifications
You must be signed in to change notification settings - Fork 4
/
AzCopyAliases.cs
executable file
·52 lines (49 loc) · 2.55 KB
/
AzCopyAliases.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System;
using Cake.Core;
using Cake.Core.Annotations;
namespace Cake.AzCopy
{
[CakeNamespaceImport("Cake.AzCopy")]
[CakeAliasCategory("Azure")]
public static class AzCopyAliases
{
/// <summary>
/// Invokes AzCopy with the given source and destination, using all the defaults
/// </summary>
/// <param name="ctx">The Cake context.</param>
/// <param name="source">The source file(s) or path(s).</param>
/// <param name="destination">The destination path.</param>
[CakeMethodAlias]
public static void AzCopy(this ICakeContext ctx, string source, string destination) {
if (ctx.Environment.Platform.Family == PlatformFamily.OSX) throw new NotSupportedException("AzCopy is not supported on macOS");
ctx.AzCopy(source, destination, new AzCopySettings());
}
/// <summary>
/// Invokes AzCopy with the given source and destination, using the given settings
/// </summary>
/// <param name="ctx">The Cake context.</param>
/// <param name="source">The source file(s) or path(s).</param>
/// <param name="destination">The destination path.</param>
/// <param name="settings">The <see cref="AzCopySettings"/> to use when copying</param>
[CakeMethodAlias]
public static void AzCopy(this ICakeContext ctx, string source, string destination, AzCopySettings settings) {
if (ctx.Environment.Platform.Family == PlatformFamily.OSX) throw new NotSupportedException("AzCopy is not supported on macOS");
var runner = new AzCopyRunner(ctx);
runner.RunTool(source, destination, settings);
}
/// <summary>
/// Invokes AzCopy with the given source and destination, using the given settings
/// </summary>
/// <param name="ctx">The Cake context.</param>
/// <param name="source">The source file(s) or path(s).</param>
/// <param name="destination">The destination path.</param>
/// <param name="settings">The settings configurator.</param>
[CakeMethodAlias]
public static void AzCopy(this ICakeContext ctx, string source, string destination, Action<AzCopySettings> configure) {
if (ctx.Environment.Platform.Family == PlatformFamily.OSX) throw new NotSupportedException("AzCopy is not supported on macOS");
var settings = new AzCopySettings();
configure?.Invoke(settings);
ctx.AzCopy(source, destination, settings);
}
}
}