Skip to content
This repository has been archived by the owner on Sep 5, 2018. It is now read-only.

Removed 'nucmd work run' command #4

Merged
merged 1 commit into from
Mar 10, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 8 additions & 28 deletions src/NuCmd/Commands/Work/JobsCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,18 @@ namespace NuCmd.Commands.Work
[Description("Lists available jobs")]
public class JobsCommand : WorkServiceCommandBase
{
[ArgShortcut("l")]
[ArgDescription("Set this flag to view only jobs available when using 'nucmd work run'")]
public bool Local { get; set; }

protected override async Task OnExecute()
{
if (Local)
var client = await OpenClient();
if (client == null) { return; }

var response = await client.Jobs.Get();

if (await ReportHttpStatus(response))
{
var jobs = await response.ReadContent();
await Console.WriteTable(
WorkService.GetAllAvailableJobs(), j => new
jobs, j => new
{
j.Name,
j.Description,
Expand All @@ -32,28 +34,6 @@ await Console.WriteTable(
j.Assembly.BuildDate
});
}
else
{
var client = await OpenClient();
if (client == null) { return; }

var response = await client.Jobs.Get();

if (await ReportHttpStatus(response))
{
var jobs = await response.ReadContent();
await Console.WriteTable(
jobs, j => new
{
j.Name,
j.Description,
j.Enabled,
Assembly = j.Assembly.FullName.Name,
j.Assembly.BuildCommit,
j.Assembly.BuildDate
});
}
}
}
}
}
95 changes: 2 additions & 93 deletions src/NuCmd/Commands/Work/RunCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,103 +13,12 @@

namespace NuCmd.Commands.Work
{
[Description("Invokes a worker job immediately, locally, and with the local console as a trace sink")]
[Description("DECOMMISSIONED. Use 'jobhost.exe' in the NuGet.Services.Work repo instead")]
public class RunCommand : Command
{
[ArgRequired()]
[ArgPosition(0)]
[ArgShortcut("j")]
[ArgDescription("The job to invoke")]
public string Job { get; set; }

[ArgShortcut("p")]
[ArgDescription("The JSON dictionary payload to provide to the job")]
public string Payload { get; set; }

[ArgShortcut("ep")]
[ArgDescription("A base64-encoded UTF8 payload string to use. Designed for command-line piping")]
public string EncodedPayload { get; set; }

[ArgShortcut("c")]
[ArgDescription("The JSON dictionary configuration to provide to the job")]
public string Configuration { get; set; }

[ArgShortcut("ec")]
[ArgDescription("A base64-encoded UTF8 configuration string to use. Designed for command-line piping")]
public string EncodedConfiguration { get; set; }

protected override async Task OnExecute()
{
if (!String.IsNullOrEmpty(EncodedPayload))
{
Payload = Encoding.UTF8.GetString(Convert.FromBase64String(EncodedPayload));
}

if (!String.IsNullOrEmpty(EncodedConfiguration))
{
Configuration = Encoding.UTF8.GetString(Convert.FromBase64String(EncodedConfiguration));
}

var configuration = InvocationPayloadSerializer.Deserialize(Configuration);

var service = await LocalWorkService.Create(configuration);

var tcs = new TaskCompletionSource<object>();

string message = String.Format(Strings.Work_RunCommand_Invoking, Job);
await Console.WriteInfoLine(message);
await Console.WriteInfoLine(new String('-', message.Length));

Exception thrown = null;
try
{
var observable = service.RunJob(Job, Payload);
observable
.Subscribe(
evt => RenderEvent(evt).Wait(),
ex => tcs.SetException(ex),
() => tcs.SetResult(null));
await tcs.Task;
}
catch (AggregateException aex)
{
thrown = aex.InnerException;
}
catch (Exception ex)
{
thrown = ex;
}
if (thrown != null)
{
await Console.WriteErrorLine(thrown.ToString());
}

message = String.Format(Strings.Work_RunCommand_Invoked, Job);
await Console.WriteInfoLine(new String('-', message.Length));
await Console.WriteInfoLine(message);
}

private async Task RenderEvent(EventEntry evt)
{
string message = evt.FormattedMessage;
switch (evt.Schema.Level)
{
case EventLevel.Critical:
await Console.WriteFatalLine(message);
break;
case EventLevel.Error:
await Console.WriteErrorLine(message);
break;
case EventLevel.Informational:
await Console.WriteInfoLine(message);
break;
case EventLevel.Verbose:
await Console.WriteTraceLine(message);
break;
case EventLevel.Warning:
await Console.WriteWarningLine(message);
break;
}
await Console.WriteErrorLine("DECOMMISSIONED. Use 'jobhost.exe' in the NuGet.Services.Work repo instead");
}
}
}
7 changes: 0 additions & 7 deletions src/NuCmd/NuCmd.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,6 @@
<Reference Include="NuGet.Services.Platform.Client">
<HintPath>..\..\packages\NuGet.Services.Platform.Client.3.0.1-rel\lib\portable-net45+wp80+win\NuGet.Services.Platform.Client.dll</HintPath>
</Reference>
<Reference Include="NuGet.Services.Work">
<HintPath>..\..\packages\NuGet.Services.Work.3.0.1-rel-4\lib\net45\NuGet.Services.Work.dll</HintPath>
</Reference>
<Reference Include="NuGet.Services.Work.Client">
<HintPath>..\..\packages\NuGet.Services.Work.Client.3.0.1-rel-4\lib\portable-net45+wp80+win\NuGet.Services.Work.Client.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -175,10 +172,6 @@
<Reference Include="System.Spatial, Version=5.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.Spatial.5.6.0\lib\net40\System.Spatial.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Dataflow, Version=4.5.14.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Microsoft.Tpl.Dataflow.4.5.14\lib\portable-net45+win8\System.Threading.Tasks.Dataflow.dll</HintPath>
</Reference>
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
Expand Down
2 changes: 0 additions & 2 deletions src/NuCmd/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<package id="Microsoft.Owin.Host.HttpListener" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.Owin.Hosting" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.Owin.Security" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.Tpl.Dataflow" version="4.5.14" targetFramework="net45" />
<package id="Microsoft.Web.Xdt" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Common" version="0.9.9-preview" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Common.Dependencies" version="0.9.1-preview" targetFramework="net45" />
Expand All @@ -39,7 +38,6 @@
<package id="Nuget.Core" version="2.8.0" targetFramework="net45" />
<package id="NuGet.Services.Platform" version="3.0.1-rel" targetFramework="net45" />
<package id="NuGet.Services.Platform.Client" version="3.0.1-rel" targetFramework="net45" />
<package id="NuGet.Services.Work" version="3.0.1-rel-4" targetFramework="net45" />
<package id="NuGet.Services.Work.Client" version="3.0.1-rel-4" targetFramework="net45" />
<package id="Owin" version="1.0" targetFramework="net45" />
<package id="PowerArgs" version="2.0.4.0-preview" targetFramework="net45" />
Expand Down