-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathProgram.cs
78 lines (70 loc) · 2.44 KB
/
Program.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using System;
using OctoClient.Models;
namespace OctoClient
{
class Program
{
static int Main(string[] args)
{
if (args.Length != 1)
{
Console.WriteLine(@"You must supply the action to take as a single argument. Available actions:
- release
- deploy
");
return 1;
}
var inputs = ActionsHelp.ReadInputValues();
if (inputs.HasErrors())
{
ActionsHelp.WriteOutput(inputs.Error);
return 1;
}
var octo = new OctoClient(inputs.Result);
switch (args[0].ToLower())
{
case "release":
inputs.Error = inputs.Result.ValidateForRelease();
if (inputs.HasErrors())
{
ActionsHelp.WriteOutput(inputs.Error);
return 1;
}
else
{
var release = octo.CreateReleaseResult();
if (release.HasErrors())
{
ActionsHelp.WriteOutput(release.Error);
return 1;
}
ActionsHelp.WriteOutput(release.Result);
}
break;
case "deploy":
inputs.Error = inputs.Result.ValidateForDeploy();
if (inputs.HasErrors())
{
ActionsHelp.WriteOutput(inputs.Error);
return 1;
}
else
{
var deployment = octo.CreateDeploymentResult();
if (deployment.HasErrors())
{
ActionsHelp.WriteOutput(deployment.Error);
return 1;
}
ActionsHelp.WriteOutput(deployment.Result);
}
break;
default:
inputs.Error.ErrorMessages.Add($"Action {args[0].ToLower()} not yet supported");
ActionsHelp.WriteOutput(inputs.Error);
return 1;
}
return 0;
}
}
}