report.OK
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Mono.Options;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
@ -12,12 +13,13 @@ namespace nuget_cli
|
||||
private static bool shouldShowPushHelp;
|
||||
private static string apiKey = null;
|
||||
private static string source = null;
|
||||
private static int pushKO = 0;
|
||||
|
||||
static Program()
|
||||
{
|
||||
}
|
||||
|
||||
static void Main(string[] args)
|
||||
static int Main(string[] args)
|
||||
{
|
||||
|
||||
var options = new OptionSet {
|
||||
@ -85,6 +87,7 @@ namespace nuget_cli
|
||||
}
|
||||
List<PushReport> reports = await PushPkgAsync(pargs);
|
||||
Console.WriteLine(JsonConvert.SerializeObject(reports));
|
||||
pushKO = reports.Count( r => !r.OK );
|
||||
}
|
||||
};
|
||||
commandSet.Add(push);
|
||||
@ -107,7 +110,7 @@ namespace nuget_cli
|
||||
Console.Write("nuget-cli: ");
|
||||
Console.WriteLine(e.Message);
|
||||
Console.WriteLine("Try `nuget-cli --help' for more information.");
|
||||
return;
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
@ -116,11 +119,14 @@ namespace nuget_cli
|
||||
// output the options
|
||||
Console.WriteLine("Options:");
|
||||
options.WriteOptionDescriptions(Console.Out);
|
||||
return;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int runCode = commandSet.Run(args);
|
||||
if (runCode == 0 ) if (pushKO>0) return 3;
|
||||
|
||||
|
||||
commandSet.Run(args);
|
||||
return runCode;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,6 @@ namespace nuget_cli
|
||||
};
|
||||
if (!fi.Exists)
|
||||
{
|
||||
report.StatusCode = "local";
|
||||
report.Message = "Le fichier n'existe pas";
|
||||
return report;
|
||||
}
|
||||
@ -37,6 +36,7 @@ namespace nuget_cli
|
||||
{
|
||||
await Console.Error.WriteLineAsync(ex.Message);
|
||||
report.StatusCode = ex.Status.ToString();
|
||||
report.OK = false;
|
||||
using (var respStream = ex.Response.GetResponseStream())
|
||||
{
|
||||
StreamReader sr = new StreamReader(respStream);
|
||||
|
@ -1,9 +1,12 @@
|
||||
using System.Net;
|
||||
|
||||
namespace nuget_cli
|
||||
{
|
||||
public class PushReport
|
||||
{
|
||||
public string PkgName { get; set; }
|
||||
public bool Executed { get; internal set; }
|
||||
public bool OK { get; internal set; }
|
||||
public bool AlreadyPresent { get; internal set; }
|
||||
public string Message { get; internal set; }
|
||||
public string StatusCode { get; internal set; }
|
||||
|
@ -60,6 +60,7 @@ namespace nuget_cli
|
||||
{
|
||||
report.Message = rex.Message;
|
||||
report.StatusCode = "internal error";
|
||||
report.OK = false;
|
||||
Console.Error.WriteLine(rex.Message);
|
||||
}
|
||||
}
|
||||
|
@ -83,7 +83,10 @@ namespace nuget_cli
|
||||
{
|
||||
String json = re.ReadToEnd();
|
||||
report.Message = json;
|
||||
report.StatusCode = (resp as HttpWebResponse).StatusCode.ToString();
|
||||
var hrep = resp as HttpWebResponse;
|
||||
report.StatusCode = hrep.StatusCode.ToString();
|
||||
report.OK = hrep.StatusCode ==
|
||||
HttpStatusCode.Accepted || hrep.StatusCode == HttpStatusCode.OK;
|
||||
}
|
||||
else throw new Exception("Invalid server response type");
|
||||
}
|
||||
|
Reference in New Issue
Block a user