Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* Fix microsoft#274

* Update DownloadTool.cs

* Update DownloadTool.cs

* Update DownloadTool.cs
  • Loading branch information
gfs authored Nov 11, 2021
1 parent b96e169 commit dd3d244
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/oss-download/DownloadTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ namespace Microsoft.CST.OpenSource
{
public class DownloadTool : OSSGadget
{
public enum ErrorCode
{
Ok,
ProcessingException,
NoTargets
}

public class Options
{
[Usage()]
Expand Down Expand Up @@ -54,14 +61,15 @@ public DownloadTool() : base()
/// Main entrypoint for the download program.
/// </summary>
/// <param name="args"> parameters passed in from the user </param>
static async Task Main(string[] args)
static async Task<int> Main(string[] args)
{
ShowToolBanner();
var downloadTool = new DownloadTool();
await downloadTool.ParseOptions<Options>(args).WithParsedAsync(downloadTool.RunAsync);
var opts = downloadTool.ParseOptions<Options>(args).Value;
return (int)(await downloadTool.RunAsync(opts));
}

private async Task RunAsync(Options options)
private async Task<ErrorCode> RunAsync(Options options)
{
if (options.Targets is IList<string> targetList && targetList.Count > 0)
{
Expand Down Expand Up @@ -90,9 +98,16 @@ private async Task RunAsync(Options options)
catch (Exception ex)
{
Logger.Warn(ex, "Error processing {0}: {1}", target, ex.Message);
return ErrorCode.ProcessingException;
}
}
}
else
{
Logger.Error("No targets were specified for downloading.");
return ErrorCode.NoTargets;
}
return ErrorCode.Ok;
}
}
}

0 comments on commit dd3d244

Please sign in to comment.