Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 0 additions & 1 deletion src/SeqCli/Apps/Hosting/AppContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
using System;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Newtonsoft.Json;
Expand Down
1 change: 0 additions & 1 deletion src/SeqCli/Apps/Hosting/AppHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

using System;
using System.Collections.Generic;
using System.Net;
using System.Threading.Tasks;
using Seq.Apps;
using Serilog;
Expand Down
1 change: 0 additions & 1 deletion src/SeqCli/Cli/Commands/ApiKey/ListCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Linq;
using System.Threading.Tasks;
using SeqCli.Api;
Expand Down
1 change: 0 additions & 1 deletion src/SeqCli/Cli/Commands/ApiKey/RemoveCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Linq;
using System.Threading.Tasks;
using SeqCli.Api;
Expand Down
1 change: 0 additions & 1 deletion src/SeqCli/Cli/Commands/App/DefineCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
using System.Threading.Tasks;
using SeqCli.Apps;
using SeqCli.Apps.Definitions;
using SeqCli.Cli.Features;
using SeqCli.Util;

namespace SeqCli.Cli.Commands.App;
Expand Down
2 changes: 0 additions & 2 deletions src/SeqCli/Cli/Commands/App/InstallCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;
using SeqCli.Api;
Expand Down
3 changes: 1 addition & 2 deletions src/SeqCli/Cli/Commands/App/ListCommand.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Linq;
using System.Linq;
using System.Threading.Tasks;
using SeqCli.Api;
using SeqCli.Cli.Features;
Expand Down
1 change: 0 additions & 1 deletion src/SeqCli/Cli/Commands/App/UninstallCommand.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using SeqCli.Api;
Expand Down
1 change: 0 additions & 1 deletion src/SeqCli/Cli/Commands/App/UpdateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// limitations under the License.

using System;
using System.Globalization;
using System.Threading.Tasks;
using SeqCli.Api;
using SeqCli.Cli.Features;
Expand Down
3 changes: 1 addition & 2 deletions src/SeqCli/Cli/Commands/AppInstance/CreateCommand.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Seq.Api.Model.AppInstances;
Expand Down
3 changes: 1 addition & 2 deletions src/SeqCli/Cli/Commands/AppInstance/ListCommand.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Linq;
using System.Linq;
using System.Threading.Tasks;
using SeqCli.Api;
using SeqCli.Cli.Features;
Expand Down
3 changes: 1 addition & 2 deletions src/SeqCli/Cli/Commands/AppInstance/RemoveCommand.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Linq;
using System.Linq;
using System.Threading.Tasks;
using SeqCli.Api;
using SeqCli.Cli.Features;
Expand Down
2 changes: 0 additions & 2 deletions src/SeqCli/Cli/Commands/Bench/BenchCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@
// limitations under the License.

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Seq.Api;
using Seq.Api.Model.Data;
using Seq.Api.Model.Signals;
using SeqCli.Api;
using SeqCli.Cli.Features;
Expand Down
3 changes: 0 additions & 3 deletions src/SeqCli/Cli/Commands/Config/SetCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.IO;
using System.Threading.Tasks;
using SeqCli.Cli.Features;
using SeqCli.Config;
using Serilog;

// ReSharper disable once UnusedType.Global

Expand Down
1 change: 0 additions & 1 deletion src/SeqCli/Cli/Commands/Dashboard/ListCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Linq;
using System.Threading.Tasks;
using SeqCli.Api;
Expand Down
1 change: 0 additions & 1 deletion src/SeqCli/Cli/Commands/Dashboard/RemoveCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Linq;
using System.Threading.Tasks;
using SeqCli.Api;
Expand Down
19 changes: 4 additions & 15 deletions src/SeqCli/Cli/Commands/Dashboard/RenderCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Seq.Api.Model.Dashboarding;
using Seq.Api.Model.Signals;
using SeqCli.Api;
Expand Down Expand Up @@ -158,20 +157,10 @@ protected override async Task<int> Run()
var timeout = _timeout.ApplyTimeout(connection.Client.HttpClient);

var output = _output.GetOutputFormat(config);
if (output.Json)
{
var result = await connection.Data.QueryAsync(q, signal: signal, timeout: timeout);

// Some friendlier JSON output is definitely possible here
Console.WriteLine(JsonConvert.SerializeObject(result));
}
else
{
var result = await connection.Data.QueryCsvAsync(q, signal: signal, timeout: timeout);
output.WriteCsv(result);
}

return 0;
var result = await connection.Data.TryQueryAsync(q, signal: signal, timeout: timeout);
output.WriteQueryResult(result);

return string.IsNullOrWhiteSpace(result.Error) ? 0 : 1;
}

static string BuildSqlQuery(ChartQueryPart query, DateTime rangeStart, DateTime rangeEnd, TimeSpan? timeGrouping)
Expand Down
4 changes: 0 additions & 4 deletions src/SeqCli/Cli/Commands/ExpressionIndex/CreateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Threading.Tasks;
using Seq.Api.Model.Signals;
using SeqCli.Api;
using SeqCli.Cli.Features;
using SeqCli.Config;
using SeqCli.Signals;
using SeqCli.Syntax;
using SeqCli.Util;
using Serilog;

Expand Down
1 change: 0 additions & 1 deletion src/SeqCli/Cli/Commands/ExpressionIndex/ListCommand.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Threading.Tasks;
using SeqCli.Api;
using SeqCli.Cli.Features;
Expand Down
1 change: 0 additions & 1 deletion src/SeqCli/Cli/Commands/Feed/ListCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Linq;
using System.Threading.Tasks;
using SeqCli.Api;
Expand Down
1 change: 0 additions & 1 deletion src/SeqCli/Cli/Commands/Feed/RemoveCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Linq;
using System.Threading.Tasks;
using SeqCli.Api;
Expand Down
4 changes: 0 additions & 4 deletions src/SeqCli/Cli/Commands/Index/ListCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Seq.Api.Model.Indexes;
using SeqCli.Api;
using SeqCli.Cli.Features;
using SeqCli.Config;
Expand Down
2 changes: 0 additions & 2 deletions src/SeqCli/Cli/Commands/Index/SuppressCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Threading.Tasks;
using Seq.Api.Model.Indexes;
using SeqCli.Api;
using SeqCli.Cli.Features;
using SeqCli.Config;
Expand Down
9 changes: 1 addition & 8 deletions src/SeqCli/Cli/Commands/License/ShowCommand.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
using System;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using Seq.Api.Model;
using Seq.Api.Model.License;
using System.Threading.Tasks;
using SeqCli.Api;
using SeqCli.Cli.Features;
using SeqCli.Config;
using SeqCli.Util;
using Serilog;

// ReSharper disable once UnusedType.Global

Expand Down
1 change: 0 additions & 1 deletion src/SeqCli/Cli/Commands/Node/ListCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Linq;
using System.Threading.Tasks;
using SeqCli.Api;
Expand Down
21 changes: 5 additions & 16 deletions src/SeqCli/Cli/Commands/QueryCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Threading.Tasks;
using Seq.Api.Client;
using SeqCli.Api;
using SeqCli.Cli.Features;
using SeqCli.Config;
Expand All @@ -24,7 +22,7 @@

namespace SeqCli.Cli.Commands;

[Command("query", "Execute an SQL query and receive results in CSV format",
[Command("query", "Execute a query and receive results in CSV, JSON, or native format",
Example = "seqcli query -q \"select count(*) from stream group by @Level\" --start=\"2018-02-28T13:00Z\"")]
class QueryCommand : Command
{
Expand All @@ -39,7 +37,7 @@ class QueryCommand : Command

public QueryCommand()
{
Options.Add("q=|query=", "The query to execute", v => _query = v);
Options.Add("q=|query=", "The Seq query to execute", v => _query = v);
_range = Enable<DateRangeFeature>();
_signal = Enable<SignalExpressionFeature>();
_timeout = Enable<TimeoutFeature>();
Expand All @@ -63,18 +61,9 @@ protected override async Task<int> Run()
var timeout = _timeout.ApplyTimeout(connection.Client.HttpClient);

var output = _output.GetOutputFormat(config);
if (output.Text)
{
// We can fold this into the `WriteQueryResult` case once that path supports themes.
var result = await connection.Data.QueryCsvAsync(_query, _range.Start, _range.End, _signal.Signal, timeout: timeout, trace: _trace);
output.WriteCsv(result);
}
else
{
var result = await connection.Data.QueryAsync(_query, _range.Start, _range.End, _signal.Signal, timeout: timeout, trace: _trace);
output.WriteQueryResult(result);
}
var result = await connection.Data.TryQueryAsync(_query, _range.Start, _range.End, _signal.Signal, timeout: timeout, trace: _trace);
output.WriteQueryResult(result);

return 0;
return string.IsNullOrWhiteSpace(result.Error) ? 0 : 1;
}
}
1 change: 0 additions & 1 deletion src/SeqCli/Cli/Commands/RetentionPolicy/ListCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Threading.Tasks;
using SeqCli.Api;
using SeqCli.Cli.Features;
Expand Down
1 change: 0 additions & 1 deletion src/SeqCli/Cli/Commands/RetentionPolicy/RemoveCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Threading.Tasks;
using SeqCli.Api;
using SeqCli.Cli.Features;
Expand Down
1 change: 0 additions & 1 deletion src/SeqCli/Cli/Commands/Sample/SetupCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using SeqCli.Cli.Features;
using SeqCli.Templates.Ast;
Expand Down
1 change: 0 additions & 1 deletion src/SeqCli/Cli/Commands/Settings/ClearCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Threading.Tasks;
using SeqCli.Api;
using SeqCli.Cli.Features;
Expand Down
1 change: 0 additions & 1 deletion src/SeqCli/Cli/Commands/Signal/ListCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Linq;
using System.Threading.Tasks;
using SeqCli.Api;
Expand Down
1 change: 0 additions & 1 deletion src/SeqCli/Cli/Commands/Signal/RemoveCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Linq;
using System.Threading.Tasks;
using SeqCli.Api;
Expand Down
3 changes: 1 addition & 2 deletions src/SeqCli/Cli/Commands/Template/ExportCommand.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using SeqCli.Api;
Expand Down
1 change: 0 additions & 1 deletion src/SeqCli/Cli/Commands/User/ListCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Linq;
using System.Threading.Tasks;
using SeqCli.Api;
Expand Down
1 change: 0 additions & 1 deletion src/SeqCli/Cli/Commands/User/RemoveCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Linq;
using System.Threading.Tasks;
using SeqCli.Api;
Expand Down
1 change: 0 additions & 1 deletion src/SeqCli/Cli/Commands/View/CreateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
using System.Linq;
using System.Threading.Tasks;
using Seq.Api.Model.Shared;
using Seq.Api.Model.Signals;
using SeqCli.Api;
using SeqCli.Cli.Features;
using SeqCli.Config;
Expand Down
1 change: 0 additions & 1 deletion src/SeqCli/Cli/Commands/View/ListCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Linq;
using System.Threading.Tasks;
using SeqCli.Api;
Expand Down
1 change: 0 additions & 1 deletion src/SeqCli/Cli/Commands/View/RemoveCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Linq;
using System.Threading.Tasks;
using SeqCli.Api;
Expand Down
Loading
Loading