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
2 changes: 1 addition & 1 deletion Build.Docker.ps1
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,7 @@ $IsCIBuild = $null -ne $env:APPVEYOR_BUILD_NUMBER
$IsPublishedBuild = ($env:APPVEYOR_REPO_BRANCH -eq "master" -or $env:APPVEYOR_REPO_BRANCH -eq "dev") -and $null -eq $env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH

$version = @{ $true = $env:APPVEYOR_BUILD_VERSION; $false = "99.99.99" }[$env:APPVEYOR_BUILD_VERSION -ne $NULL];
$framework = "netcoreapp2.2"
$framework = "netcoreapp3.1"
$rid = "linux-x64"
$tag = "datalust/seqcli-ci:$version"

Expand Down
2 changes: 1 addition & 1 deletion Build.ps1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
$ErrorActionPreference = 'Stop'

$framework = 'netcoreapp2.2'
$framework = 'netcoreapp3.1'

function Clean-Output
{
Expand Down
195 changes: 141 additions & 54 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion appveyor.yml
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
version: 5.1.{build}
version: 2020.1.{build}
skip_tags: true
image:
- Visual Studio 2019
Expand Down
2 changes: 1 addition & 1 deletion dockerfiles/seqcli/Dockerfile
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,7 +17,7 @@ RUN apt-get update \
&& rm -rf /var/lib/apt/lists/*

COPY dockerfiles/seqcli/run.sh /run.sh
COPY src/SeqCli/bin/Release/netcoreapp2.2/linux-x64/publish /bin/seqcli
COPY src/SeqCli/bin/Release/netcoreapp3.1/linux-x64/publish /bin/seqcli

ENTRYPOINT ["/run.sh"]

Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "2.2.105"
"version": "3.1.201"
}
}
21 changes: 13 additions & 8 deletions seqcli.sln
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,12 +14,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sln", "sln", "{2EA56595-519
LICENSE = LICENSE
README.md = README.md
SeqCli.Runtime.targets = SeqCli.Runtime.targets
setup.sh = setup.sh
Build.Docker.ps1 = Build.Docker.ps1
docker-publish.ps1 = docker-publish.ps1
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{3587B633-0C03-4235-8903-6226900328F1}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "setup", "setup", "{203E8AE7-ADF0-44FA-A341-90723C8595F7}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "asset", "asset", "{438A0DA5-F3CF-4FCE-B43A-B6DA2981D4AE}"
ProjectSection(SolutionItems) = preProject
asset\SeqCli-Icon-128px.ico = asset\SeqCli-Icon-128px.ico
Expand All@@ -32,10 +33,17 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SeqCli", "src\SeqCli\SeqCli
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SeqCli.Tests", "test\SeqCli.Tests\SeqCli.Tests.csproj", "{DBC69360-519B-4A9B-829B-2AE1B5412521}"
EndProject
Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "SeqCli.Setup", "setup\SeqCli.Setup\SeqCli.Setup.wixproj", "{5E28D963-3523-49DE-B03B-E76684258415}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SeqCli.EndToEnd", "test\SeqCli.EndToEnd\SeqCli.EndToEnd.csproj", "{B86DEF3C-C461-4126-AD49-986EBB19B487}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dockerfiles", "dockerfiles", "{0779824B-502D-450B-BB43-036949C911C4}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "seqcli", "seqcli", "{7F7CAC3A-1046-4D2B-BF9F-F14525918295}"
ProjectSection(SolutionItems) = preProject
dockerfiles\seqcli\.gitignore = dockerfiles\seqcli\.gitignore
dockerfiles\seqcli\Dockerfile = dockerfiles\seqcli\Dockerfile
dockerfiles\seqcli\run.sh = dockerfiles\seqcli\run.sh
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Expand All@@ -50,9 +58,6 @@ Global
{DBC69360-519B-4A9B-829B-2AE1B5412521}.Debug|x64.Build.0 = Debug|x64
{DBC69360-519B-4A9B-829B-2AE1B5412521}.Release|x64.ActiveCfg = Release|x64
{DBC69360-519B-4A9B-829B-2AE1B5412521}.Release|x64.Build.0 = Release|x64
{5E28D963-3523-49DE-B03B-E76684258415}.Debug|x64.ActiveCfg = Debug|x64
{5E28D963-3523-49DE-B03B-E76684258415}.Release|x64.ActiveCfg = Release|x64
{5E28D963-3523-49DE-B03B-E76684258415}.Release|x64.Build.0 = Release|x64
{B86DEF3C-C461-4126-AD49-986EBB19B487}.Debug|x64.ActiveCfg = Debug|x64
{B86DEF3C-C461-4126-AD49-986EBB19B487}.Debug|x64.Build.0 = Debug|x64
{B86DEF3C-C461-4126-AD49-986EBB19B487}.Release|x64.ActiveCfg = Release|x64
Expand All@@ -64,8 +69,8 @@ Global
GlobalSection(NestedProjects) = preSolution
{EBDBEED2-A1BC-4269-B6B0-EA908CE4D687} = {FC0A256C-CC1F-4ECE-AF09-707248D10DC1}
{DBC69360-519B-4A9B-829B-2AE1B5412521} = {3587B633-0C03-4235-8903-6226900328F1}
{5E28D963-3523-49DE-B03B-E76684258415} = {203E8AE7-ADF0-44FA-A341-90723C8595F7}
{B86DEF3C-C461-4126-AD49-986EBB19B487} = {3587B633-0C03-4235-8903-6226900328F1}
{7F7CAC3A-1046-4D2B-BF9F-F14525918295} = {0779824B-502D-450B-BB43-036949C911C4}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6D299713-28D4-4078-9DA7-9033679CD200}
Expand Down
10 changes: 5 additions & 5 deletions src/SeqCli/Cli/Commands/ApiKey/CreateCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,7 +17,7 @@
using System.Threading.Tasks;
using Seq.Api.Model.Inputs;
using Seq.Api.Model.LogEvents;
using Seq.Api.Model.Signals;
using Seq.Api.Model.Shared;
using SeqCli.Cli.Features;
using SeqCli.Config;
using SeqCli.Connection;
Expand DownExpand Up@@ -82,17 +82,17 @@ protected override async Task<int> Run()
var apiKey = await connection.ApiKeys.TemplateAsync();

apiKey.Title = _title;
apiKey.AppliedProperties = _properties.Properties
apiKey.InputSettings.AppliedProperties = _properties.Properties
.Select(kvp => new InputAppliedPropertyPart {Name = kvp.Key, Value = kvp.Value})
.ToList();
apiKey.UseServerTimestamps = _useServerTimestamps;
apiKey.InputSettings.UseServerTimestamps = _useServerTimestamps;

// If _token is null, a value will be returned when the key is created
apiKey.Token = _token;

if (_filter != null)
{
apiKey.InputFilter = new SignalFilterPart
apiKey.InputSettings.Filter = new DescriptiveFilterPart
{
Filter = (await connection.Expressions.ToStrictAsync(_filter)).StrictExpression,
FilterNonStrict = _filter
Expand All@@ -101,7 +101,7 @@ protected override async Task<int> Run()

if (_level != null)
{
apiKey.MinimumLevel = Enum.Parse<LogEventLevel>(LevelMapping.ToFullLevelName(_level));
apiKey.InputSettings.MinimumLevel = Enum.Parse<LogEventLevel>(LevelMapping.ToFullLevelName(_level));
}

apiKey = await connection.ApiKeys.AddAsync(apiKey);
Expand Down
7 changes: 4 additions & 3 deletions src/SeqCli/Cli/Commands/Dashboard/RenderCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,9 +39,9 @@ class RenderCommand : Command
readonly ConnectionFeature _connection;
readonly OutputFormatFeature _output;
readonly SignalExpressionFeature _signal;
readonly TimeoutFeature _timeout;

string _id, _lastDuration, _intervalDuration, _chartTitle;
int? _timeoutMS;

public RenderCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config)
{
Expand All@@ -62,7 +62,7 @@ public RenderCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config
v => _intervalDuration = ArgumentString.Normalize(v));
_range = Enable<DateRangeFeature>();
_signal = Enable<SignalExpressionFeature>();
Options.Add("timeout=", "The query execution timeout in milliseconds", v => _timeoutMS = int.Parse(v?.Trim() ?? "0"));
_timeout = Enable<TimeoutFeature>();
_output = Enable(new OutputFormatFeature(config.Output));
_connection = Enable<ConnectionFeature>();
}
Expand DownExpand Up@@ -158,7 +158,8 @@ protected override async Task<int> Run()

var q = BuildSqlQuery(query, rangeStart, rangeEnd, timeGrouping);

var timeout = _timeoutMS.HasValue ? TimeSpan.FromMilliseconds(_timeoutMS.Value) : (TimeSpan?)null;
var timeout = _timeout.ApplyTimeout(connection.Client.HttpClient);

if (_output.Json)
{
var result = await connection.Data.QueryAsync(q, signal: signal, timeout: timeout);
Expand Down
6 changes: 5 additions & 1 deletion src/SeqCli/Cli/Commands/HelpCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -96,7 +96,11 @@ void PrintMarkdownHelp(string executableName)
{
if (cmd.Count() == 1)
{
Console.WriteLine($" - [`{cmd.Key}`](#{cmd.Key}) &mdash; {cmd.Single().Metadata.HelpText}.");
var single = cmd.Single();
if (single.Metadata.SubCommand == null)
Console.WriteLine($" - [`{cmd.Key}`](#{cmd.Key}) &mdash; {single.Metadata.HelpText}.");
else
Console.WriteLine($" - [`{cmd.Key} {single.Metadata.SubCommand}`](#{cmd.Key}-{single.Metadata.SubCommand}) &mdash; {single.Metadata.HelpText}.");
}
else
{
Expand Down
16 changes: 6 additions & 10 deletions src/SeqCli/Cli/Commands/QueryCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,6 +20,8 @@
using SeqCli.Connection;
using Serilog;

// ReSharper disable UnusedType.Global

namespace SeqCli.Cli.Commands
{
[Command("query", "Execute an SQL query and receive results in CSV format",
Expand All@@ -31,8 +33,8 @@ class QueryCommand : Command
readonly ConnectionFeature _connection;
readonly DateRangeFeature _range;
readonly SignalExpressionFeature _signal;
readonly TimeoutFeature _timeout;
string _query;
int? _timeoutMS;

public QueryCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config)
{
Expand All@@ -41,7 +43,7 @@ public QueryCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config)
Options.Add("q=|query=", "The query to execute", v => _query = v);
_range = Enable<DateRangeFeature>();
_signal = Enable<SignalExpressionFeature>();
Options.Add("timeout=", "The query execution timeout in milliseconds", v => _timeoutMS = int.Parse(v?.Trim() ?? "0"));
_timeout = Enable<TimeoutFeature>();
_output = Enable(new OutputFormatFeature(config.Output));
_connection = Enable<ConnectionFeature>();
}
Expand All@@ -55,15 +57,9 @@ protected override async Task<int> Run()
}

var connection = _connectionFactory.Connect(_connection);

var timeout = _timeoutMS.HasValue ? TimeSpan.FromMilliseconds(_timeoutMS.Value) : (TimeSpan?)null;
if (timeout != null)
{
// The timeout is applied server-side; allowing an extra 10 seconds here means that the
// user experience will be consistent - the error message will be the server's message, etc.
connection.Client.HttpClient.Timeout = timeout.Value.Add(TimeSpan.FromSeconds(10));
}

var timeout = _timeout.ApplyTimeout(connection.Client.HttpClient);

if (_output.Json)
{
var result = await connection.Data.QueryAsync(_query, _range.Start, _range.End, _signal.Signal, timeout: timeout);
Expand Down
3 changes: 2 additions & 1 deletion src/SeqCli/Cli/Commands/Signal/CreateCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,7 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Seq.Api.Model.Shared;
using Seq.Api.Model.Signals;
using SeqCli.Cli.Features;
using SeqCli.Config;
Expand DownExpand Up@@ -101,7 +102,7 @@ protected override async Task<int> Run()
{
signal.Filters = new[]
{
new SignalFilterPart
new DescriptiveFilterPart
{
Filter = (await connection.Expressions.ToStrictAsync(_filter)).StrictExpression,
FilterNonStrict = _filter
Expand Down
2 changes: 1 addition & 1 deletion src/SeqCli/Cli/Commands/Signal/ImportCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -69,7 +69,7 @@ protected override async Task<int> Run()
dest.Grouping = src.Grouping;
dest.IsProtected = src.IsProtected;
dest.Filters = src.Filters;
dest.TaggedProperties = src.TaggedProperties;
dest.Columns = src.Columns;
dest.OwnerId = _entityOwner.OwnerId;
await connection.Signals.AddAsync(dest);
}
Expand Down
3 changes: 2 additions & 1 deletion src/SeqCli/Cli/Commands/User/CreateCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,7 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Seq.Api.Model.Shared;
using Seq.Api.Model.Signals;
using SeqCli.Cli.Features;
using SeqCli.Config;
Expand DownExpand Up@@ -128,7 +129,7 @@ protected override async Task<int> Run()

if (_filter != null)
{
user.ViewFilter = new SignalFilterPart
user.ViewFilter = new DescriptiveFilterPart
{
Filter = (await connection.Expressions.ToStrictAsync(_filter)).StrictExpression,
FilterNonStrict = _filter
Expand Down
46 changes: 46 additions & 0 deletions src/SeqCli/Cli/Features/TimeoutFeature.cs
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
// Copyright Datalust Pty Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Net.Http;

namespace SeqCli.Cli.Features
{
class TimeoutFeature: CommandFeature
{
int? _timeoutMS;

public override void Enable(OptionSet options)
{
options.Add("timeout=", "The execution timeout in milliseconds", v => _timeoutMS = int.Parse(v?.Trim() ?? "0"));
}

// Ensures we don't forget to configure the client whenever the server is given a longer timeout than
// the client's internal default.
public TimeSpan? ApplyTimeout(HttpClient httpClient)
{
if (httpClient == null) throw new ArgumentNullException(nameof(httpClient));

var timeout = _timeoutMS.HasValue ? TimeSpan.FromMilliseconds(_timeoutMS.Value) : (TimeSpan?)null;
if (timeout != null)
{
// The timeout is applied server-side; allowing an extra 10 seconds here means that the
// user experience will be consistent - the error message will be the server's message, etc.
httpClient.Timeout = timeout.Value.Add(TimeSpan.FromSeconds(10));
}

return timeout;
}
}
}
6 changes: 3 additions & 3 deletions src/SeqCli/SeqCli.csproj
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp2.2</TargetFrameworks>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AssemblyName>seqcli</AssemblyName>
<ApplicationIcon>..\..\asset\SeqCli.ico</ApplicationIcon>
<RuntimeIdentifiers>win-x64;linux-x64;osx-x64</RuntimeIdentifiers>
<GenerateAssemblyInformationalVersionAttribute>True</GenerateAssemblyInformationalVersionAttribute>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<TreatSpecificWarningsAsErrors />
<Platforms>x64</Platforms>
<LangVersion>7.3</LangVersion>
<LangVersion>8</LangVersion>
</PropertyGroup>
<Import Project="..\..\SeqCli.Runtime.targets" />
<ItemGroup>
Expand All@@ -30,7 +30,7 @@
<PackageReference Include="Superpower" Version="2.3.0" />
<PackageReference Include="System.Reactive" Version="4.3.1" />
<PackageReference Include="System.Security.Cryptography.ProtectedData" Version="4.7.0" />
<PackageReference Include="Seq.Api" Version="5.1.2-*" />
<PackageReference Include="Seq.Api" Version="2020.1.0" />
<PackageReference Include="Seq.Apps" Version="5.1.0" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions test/SeqCli.EndToEnd/SeqCli.EndToEnd.csproj
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,9 +2,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp2.2</TargetFrameworks>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Platforms>x64</Platforms>
<LangVersion>7.3</LangVersion>
<LangVersion>8</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Autofac" Version="4.9.4" />
Expand Down
7 changes: 2 additions & 5 deletions test/SeqCli.Tests/Cli/NoDuplicateCommands.cs
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq;
using System.Reflection;
using System.Text;
using SeqCli.Cli;
using Xunit;

Expand All@@ -20,7 +17,7 @@ public void EnsureNoDuplicateCommands()
.GroupBy(t => new {t.Attribute.Name, t.Attribute.SubCommand})
.Any(t => t.Count() > 1);

Assert.Equal(anyDuplicates, false);
Assert.False(anyDuplicates);
}
}
}
1 change: 0 additions & 1 deletion test/SeqCli.Tests/PlainText/FrameReaderTests.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,6 @@
using System.IO;
using System.Text;
using System.Threading.Tasks;
using SeqCli.PlainText;
using SeqCli.PlainText.Framing;
using SeqCli.PlainText.Parsers;
using Superpower;
Expand Down
3 changes: 2 additions & 1 deletion test/SeqCli.Tests/SeqCli.Tests.csproj
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Platforms>x64</Platforms>
<LangVersion>8</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content
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
2 changes: 1 addition & 1 deletion Build.Docker.ps1
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,7 @@ $IsCIBuild = $null -ne $env:APPVEYOR_BUILD_NUMBER
$IsPublishedBuild = ($env:APPVEYOR_REPO_BRANCH -eq "master" -or $env:APPVEYOR_REPO_BRANCH -eq "dev") -and $null -eq $env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH

$version = @{ $true = $env:APPVEYOR_BUILD_VERSION; $false = "99.99.99" }[$env:APPVEYOR_BUILD_VERSION -ne $NULL];
$framework = "netcoreapp2.2"
$framework = "netcoreapp3.1"
$rid = "linux-x64"
$tag = "datalust/seqcli-ci:$version"

Expand Down
2 changes: 1 addition & 1 deletion Build.ps1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
$ErrorActionPreference = 'Stop'

$framework = 'netcoreapp2.2'
$framework = 'netcoreapp3.1'

function Clean-Output
{
Expand Down
195 changes: 141 additions & 54 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion appveyor.yml
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
version: 5.1.{build}
version: 2020.1.{build}
skip_tags: true
image:
- Visual Studio 2019
Expand Down
2 changes: 1 addition & 1 deletion dockerfiles/seqcli/Dockerfile
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,7 +17,7 @@ RUN apt-get update \
&& rm -rf /var/lib/apt/lists/*

COPY dockerfiles/seqcli/run.sh /run.sh
COPY src/SeqCli/bin/Release/netcoreapp2.2/linux-x64/publish /bin/seqcli
COPY src/SeqCli/bin/Release/netcoreapp3.1/linux-x64/publish /bin/seqcli

ENTRYPOINT ["/run.sh"]

Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "2.2.105"
"version": "3.1.201"
}
}
21 changes: 13 additions & 8 deletions seqcli.sln
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,12 +14,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sln", "sln", "{2EA56595-519
LICENSE = LICENSE
README.md = README.md
SeqCli.Runtime.targets = SeqCli.Runtime.targets
setup.sh = setup.sh
Build.Docker.ps1 = Build.Docker.ps1
docker-publish.ps1 = docker-publish.ps1
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{3587B633-0C03-4235-8903-6226900328F1}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "setup", "setup", "{203E8AE7-ADF0-44FA-A341-90723C8595F7}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "asset", "asset", "{438A0DA5-F3CF-4FCE-B43A-B6DA2981D4AE}"
ProjectSection(SolutionItems) = preProject
asset\SeqCli-Icon-128px.ico = asset\SeqCli-Icon-128px.ico
Expand All@@ -32,10 +33,17 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SeqCli", "src\SeqCli\SeqCli
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SeqCli.Tests", "test\SeqCli.Tests\SeqCli.Tests.csproj", "{DBC69360-519B-4A9B-829B-2AE1B5412521}"
EndProject
Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "SeqCli.Setup", "setup\SeqCli.Setup\SeqCli.Setup.wixproj", "{5E28D963-3523-49DE-B03B-E76684258415}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SeqCli.EndToEnd", "test\SeqCli.EndToEnd\SeqCli.EndToEnd.csproj", "{B86DEF3C-C461-4126-AD49-986EBB19B487}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dockerfiles", "dockerfiles", "{0779824B-502D-450B-BB43-036949C911C4}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "seqcli", "seqcli", "{7F7CAC3A-1046-4D2B-BF9F-F14525918295}"
ProjectSection(SolutionItems) = preProject
dockerfiles\seqcli\.gitignore = dockerfiles\seqcli\.gitignore
dockerfiles\seqcli\Dockerfile = dockerfiles\seqcli\Dockerfile
dockerfiles\seqcli\run.sh = dockerfiles\seqcli\run.sh
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Expand All@@ -50,9 +58,6 @@ Global
{DBC69360-519B-4A9B-829B-2AE1B5412521}.Debug|x64.Build.0 = Debug|x64
{DBC69360-519B-4A9B-829B-2AE1B5412521}.Release|x64.ActiveCfg = Release|x64
{DBC69360-519B-4A9B-829B-2AE1B5412521}.Release|x64.Build.0 = Release|x64
{5E28D963-3523-49DE-B03B-E76684258415}.Debug|x64.ActiveCfg = Debug|x64
{5E28D963-3523-49DE-B03B-E76684258415}.Release|x64.ActiveCfg = Release|x64
{5E28D963-3523-49DE-B03B-E76684258415}.Release|x64.Build.0 = Release|x64
{B86DEF3C-C461-4126-AD49-986EBB19B487}.Debug|x64.ActiveCfg = Debug|x64
{B86DEF3C-C461-4126-AD49-986EBB19B487}.Debug|x64.Build.0 = Debug|x64
{B86DEF3C-C461-4126-AD49-986EBB19B487}.Release|x64.ActiveCfg = Release|x64
Expand All@@ -64,8 +69,8 @@ Global
GlobalSection(NestedProjects) = preSolution
{EBDBEED2-A1BC-4269-B6B0-EA908CE4D687} = {FC0A256C-CC1F-4ECE-AF09-707248D10DC1}
{DBC69360-519B-4A9B-829B-2AE1B5412521} = {3587B633-0C03-4235-8903-6226900328F1}
{5E28D963-3523-49DE-B03B-E76684258415} = {203E8AE7-ADF0-44FA-A341-90723C8595F7}
{B86DEF3C-C461-4126-AD49-986EBB19B487} = {3587B633-0C03-4235-8903-6226900328F1}
{7F7CAC3A-1046-4D2B-BF9F-F14525918295} = {0779824B-502D-450B-BB43-036949C911C4}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6D299713-28D4-4078-9DA7-9033679CD200}
Expand Down
10 changes: 5 additions & 5 deletions src/SeqCli/Cli/Commands/ApiKey/CreateCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,7 +17,7 @@
using System.Threading.Tasks;
using Seq.Api.Model.Inputs;
using Seq.Api.Model.LogEvents;
using Seq.Api.Model.Signals;
using Seq.Api.Model.Shared;
using SeqCli.Cli.Features;
using SeqCli.Config;
using SeqCli.Connection;
Expand DownExpand Up@@ -82,17 +82,17 @@ protected override async Task<int> Run()
var apiKey = await connection.ApiKeys.TemplateAsync();

apiKey.Title = _title;
apiKey.AppliedProperties = _properties.Properties
apiKey.InputSettings.AppliedProperties = _properties.Properties
.Select(kvp => new InputAppliedPropertyPart {Name = kvp.Key, Value = kvp.Value})
.ToList();
apiKey.UseServerTimestamps = _useServerTimestamps;
apiKey.InputSettings.UseServerTimestamps = _useServerTimestamps;

// If _token is null, a value will be returned when the key is created
apiKey.Token = _token;

if (_filter != null)
{
apiKey.InputFilter = new SignalFilterPart
apiKey.InputSettings.Filter = new DescriptiveFilterPart
{
Filter = (await connection.Expressions.ToStrictAsync(_filter)).StrictExpression,
FilterNonStrict = _filter
Expand All@@ -101,7 +101,7 @@ protected override async Task<int> Run()

if (_level != null)
{
apiKey.MinimumLevel = Enum.Parse<LogEventLevel>(LevelMapping.ToFullLevelName(_level));
apiKey.InputSettings.MinimumLevel = Enum.Parse<LogEventLevel>(LevelMapping.ToFullLevelName(_level));
}

apiKey = await connection.ApiKeys.AddAsync(apiKey);
Expand Down
7 changes: 4 additions & 3 deletions src/SeqCli/Cli/Commands/Dashboard/RenderCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,9 +39,9 @@ class RenderCommand : Command
readonly ConnectionFeature _connection;
readonly OutputFormatFeature _output;
readonly SignalExpressionFeature _signal;
readonly TimeoutFeature _timeout;

string _id, _lastDuration, _intervalDuration, _chartTitle;
int? _timeoutMS;

public RenderCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config)
{
Expand All@@ -62,7 +62,7 @@ public RenderCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config
v => _intervalDuration = ArgumentString.Normalize(v));
_range = Enable<DateRangeFeature>();
_signal = Enable<SignalExpressionFeature>();
Options.Add("timeout=", "The query execution timeout in milliseconds", v => _timeoutMS = int.Parse(v?.Trim() ?? "0"));
_timeout = Enable<TimeoutFeature>();
_output = Enable(new OutputFormatFeature(config.Output));
_connection = Enable<ConnectionFeature>();
}
Expand DownExpand Up@@ -158,7 +158,8 @@ protected override async Task<int> Run()

var q = BuildSqlQuery(query, rangeStart, rangeEnd, timeGrouping);

var timeout = _timeoutMS.HasValue ? TimeSpan.FromMilliseconds(_timeoutMS.Value) : (TimeSpan?)null;
var timeout = _timeout.ApplyTimeout(connection.Client.HttpClient);

if (_output.Json)
{
var result = await connection.Data.QueryAsync(q, signal: signal, timeout: timeout);
Expand Down
6 changes: 5 additions & 1 deletion src/SeqCli/Cli/Commands/HelpCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -96,7 +96,11 @@ void PrintMarkdownHelp(string executableName)
{
if (cmd.Count() == 1)
{
Console.WriteLine($" - [`{cmd.Key}`](#{cmd.Key}) &mdash; {cmd.Single().Metadata.HelpText}.");
var single = cmd.Single();
if (single.Metadata.SubCommand == null)
Console.WriteLine($" - [`{cmd.Key}`](#{cmd.Key}) &mdash; {single.Metadata.HelpText}.");
else
Console.WriteLine($" - [`{cmd.Key} {single.Metadata.SubCommand}`](#{cmd.Key}-{single.Metadata.SubCommand}) &mdash; {single.Metadata.HelpText}.");
}
else
{
Expand Down
16 changes: 6 additions & 10 deletions src/SeqCli/Cli/Commands/QueryCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,6 +20,8 @@
using SeqCli.Connection;
using Serilog;

// ReSharper disable UnusedType.Global

namespace SeqCli.Cli.Commands
{
[Command("query", "Execute an SQL query and receive results in CSV format",
Expand All@@ -31,8 +33,8 @@ class QueryCommand : Command
readonly ConnectionFeature _connection;
readonly DateRangeFeature _range;
readonly SignalExpressionFeature _signal;
readonly TimeoutFeature _timeout;
string _query;
int? _timeoutMS;

public QueryCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config)
{
Expand All@@ -41,7 +43,7 @@ public QueryCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config)
Options.Add("q=|query=", "The query to execute", v => _query = v);
_range = Enable<DateRangeFeature>();
_signal = Enable<SignalExpressionFeature>();
Options.Add("timeout=", "The query execution timeout in milliseconds", v => _timeoutMS = int.Parse(v?.Trim() ?? "0"));
_timeout = Enable<TimeoutFeature>();
_output = Enable(new OutputFormatFeature(config.Output));
_connection = Enable<ConnectionFeature>();
}
Expand All@@ -55,15 +57,9 @@ protected override async Task<int> Run()
}

var connection = _connectionFactory.Connect(_connection);

var timeout = _timeoutMS.HasValue ? TimeSpan.FromMilliseconds(_timeoutMS.Value) : (TimeSpan?)null;
if (timeout != null)
{
// The timeout is applied server-side; allowing an extra 10 seconds here means that the
// user experience will be consistent - the error message will be the server's message, etc.
connection.Client.HttpClient.Timeout = timeout.Value.Add(TimeSpan.FromSeconds(10));
}

var timeout = _timeout.ApplyTimeout(connection.Client.HttpClient);

if (_output.Json)
{
var result = await connection.Data.QueryAsync(_query, _range.Start, _range.End, _signal.Signal, timeout: timeout);
Expand Down
3 changes: 2 additions & 1 deletion src/SeqCli/Cli/Commands/Signal/CreateCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,7 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Seq.Api.Model.Shared;
using Seq.Api.Model.Signals;
using SeqCli.Cli.Features;
using SeqCli.Config;
Expand DownExpand Up@@ -101,7 +102,7 @@ protected override async Task<int> Run()
{
signal.Filters = new[]
{
new SignalFilterPart
new DescriptiveFilterPart
{
Filter = (await connection.Expressions.ToStrictAsync(_filter)).StrictExpression,
FilterNonStrict = _filter
Expand Down
2 changes: 1 addition & 1 deletion src/SeqCli/Cli/Commands/Signal/ImportCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -69,7 +69,7 @@ protected override async Task<int> Run()
dest.Grouping = src.Grouping;
dest.IsProtected = src.IsProtected;
dest.Filters = src.Filters;
dest.TaggedProperties = src.TaggedProperties;
dest.Columns = src.Columns;
dest.OwnerId = _entityOwner.OwnerId;
await connection.Signals.AddAsync(dest);
}
Expand Down
3 changes: 2 additions & 1 deletion src/SeqCli/Cli/Commands/User/CreateCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,7 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Seq.Api.Model.Shared;
using Seq.Api.Model.Signals;
using SeqCli.Cli.Features;
using SeqCli.Config;
Expand DownExpand Up@@ -128,7 +129,7 @@ protected override async Task<int> Run()

if (_filter != null)
{
user.ViewFilter = new SignalFilterPart
user.ViewFilter = new DescriptiveFilterPart
{
Filter = (await connection.Expressions.ToStrictAsync(_filter)).StrictExpression,
FilterNonStrict = _filter
Expand Down
46 changes: 46 additions & 0 deletions src/SeqCli/Cli/Features/TimeoutFeature.cs
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
// Copyright Datalust Pty Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Net.Http;

namespace SeqCli.Cli.Features
{
class TimeoutFeature: CommandFeature
{
int? _timeoutMS;

public override void Enable(OptionSet options)
{
options.Add("timeout=", "The execution timeout in milliseconds", v => _timeoutMS = int.Parse(v?.Trim() ?? "0"));
}

// Ensures we don't forget to configure the client whenever the server is given a longer timeout than
// the client's internal default.
public TimeSpan? ApplyTimeout(HttpClient httpClient)
{
if (httpClient == null) throw new ArgumentNullException(nameof(httpClient));

var timeout = _timeoutMS.HasValue ? TimeSpan.FromMilliseconds(_timeoutMS.Value) : (TimeSpan?)null;
if (timeout != null)
{
// The timeout is applied server-side; allowing an extra 10 seconds here means that the
// user experience will be consistent - the error message will be the server's message, etc.
httpClient.Timeout = timeout.Value.Add(TimeSpan.FromSeconds(10));
}

return timeout;
}
}
}
6 changes: 3 additions & 3 deletions src/SeqCli/SeqCli.csproj
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp2.2</TargetFrameworks>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AssemblyName>seqcli</AssemblyName>
<ApplicationIcon>..\..\asset\SeqCli.ico</ApplicationIcon>
<RuntimeIdentifiers>win-x64;linux-x64;osx-x64</RuntimeIdentifiers>
<GenerateAssemblyInformationalVersionAttribute>True</GenerateAssemblyInformationalVersionAttribute>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<TreatSpecificWarningsAsErrors />
<Platforms>x64</Platforms>
<LangVersion>7.3</LangVersion>
<LangVersion>8</LangVersion>
</PropertyGroup>
<Import Project="..\..\SeqCli.Runtime.targets" />
<ItemGroup>
Expand All@@ -30,7 +30,7 @@
<PackageReference Include="Superpower" Version="2.3.0" />
<PackageReference Include="System.Reactive" Version="4.3.1" />
<PackageReference Include="System.Security.Cryptography.ProtectedData" Version="4.7.0" />
<PackageReference Include="Seq.Api" Version="5.1.2-*" />
<PackageReference Include="Seq.Api" Version="2020.1.0" />
<PackageReference Include="Seq.Apps" Version="5.1.0" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions test/SeqCli.EndToEnd/SeqCli.EndToEnd.csproj
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,9 +2,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp2.2</TargetFrameworks>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Platforms>x64</Platforms>
<LangVersion>7.3</LangVersion>
<LangVersion>8</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Autofac" Version="4.9.4" />
Expand Down
7 changes: 2 additions & 5 deletions test/SeqCli.Tests/Cli/NoDuplicateCommands.cs
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq;
using System.Reflection;
using System.Text;
using SeqCli.Cli;
using Xunit;

Expand All@@ -20,7 +17,7 @@ public void EnsureNoDuplicateCommands()
.GroupBy(t => new {t.Attribute.Name, t.Attribute.SubCommand})
.Any(t => t.Count() > 1);

Assert.Equal(anyDuplicates, false);
Assert.False(anyDuplicates);
}
}
}
1 change: 0 additions & 1 deletion test/SeqCli.Tests/PlainText/FrameReaderTests.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,6 @@
using System.IO;
using System.Text;
using System.Threading.Tasks;
using SeqCli.PlainText;
using SeqCli.PlainText.Framing;
using SeqCli.PlainText.Parsers;
using Superpower;
Expand Down
3 changes: 2 additions & 1 deletion test/SeqCli.Tests/SeqCli.Tests.csproj
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Platforms>x64</Platforms>
<LangVersion>8</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
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
2 changes: 1 addition & 1 deletion Build.Docker.ps1
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,7 @@ $IsCIBuild = $null -ne $env:APPVEYOR_BUILD_NUMBER
$IsPublishedBuild = ($env:APPVEYOR_REPO_BRANCH -eq "master" -or $env:APPVEYOR_REPO_BRANCH -eq "dev") -and $null -eq $env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH

$version = @{ $true = $env:APPVEYOR_BUILD_VERSION; $false = "99.99.99" }[$env:APPVEYOR_BUILD_VERSION -ne $NULL];
$framework = "netcoreapp2.2"
$framework = "netcoreapp3.1"
$rid = "linux-x64"
$tag = "datalust/seqcli-ci:$version"

Expand Down
2 changes: 1 addition & 1 deletion Build.ps1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
$ErrorActionPreference = 'Stop'

$framework = 'netcoreapp2.2'
$framework = 'netcoreapp3.1'

function Clean-Output
{
Expand Down
195 changes: 141 additions & 54 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion appveyor.yml
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
version: 5.1.{build}
version: 2020.1.{build}
skip_tags: true
image:
- Visual Studio 2019
Expand Down
2 changes: 1 addition & 1 deletion dockerfiles/seqcli/Dockerfile
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,7 +17,7 @@ RUN apt-get update \
&& rm -rf /var/lib/apt/lists/*

COPY dockerfiles/seqcli/run.sh /run.sh
COPY src/SeqCli/bin/Release/netcoreapp2.2/linux-x64/publish /bin/seqcli
COPY src/SeqCli/bin/Release/netcoreapp3.1/linux-x64/publish /bin/seqcli

ENTRYPOINT ["/run.sh"]

Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "2.2.105"
"version": "3.1.201"
}
}
21 changes: 13 additions & 8 deletions seqcli.sln
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,12 +14,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sln", "sln", "{2EA56595-519
LICENSE = LICENSE
README.md = README.md
SeqCli.Runtime.targets = SeqCli.Runtime.targets
setup.sh = setup.sh
Build.Docker.ps1 = Build.Docker.ps1
docker-publish.ps1 = docker-publish.ps1
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{3587B633-0C03-4235-8903-6226900328F1}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "setup", "setup", "{203E8AE7-ADF0-44FA-A341-90723C8595F7}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "asset", "asset", "{438A0DA5-F3CF-4FCE-B43A-B6DA2981D4AE}"
ProjectSection(SolutionItems) = preProject
asset\SeqCli-Icon-128px.ico = asset\SeqCli-Icon-128px.ico
Expand All@@ -32,10 +33,17 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SeqCli", "src\SeqCli\SeqCli
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SeqCli.Tests", "test\SeqCli.Tests\SeqCli.Tests.csproj", "{DBC69360-519B-4A9B-829B-2AE1B5412521}"
EndProject
Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "SeqCli.Setup", "setup\SeqCli.Setup\SeqCli.Setup.wixproj", "{5E28D963-3523-49DE-B03B-E76684258415}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SeqCli.EndToEnd", "test\SeqCli.EndToEnd\SeqCli.EndToEnd.csproj", "{B86DEF3C-C461-4126-AD49-986EBB19B487}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dockerfiles", "dockerfiles", "{0779824B-502D-450B-BB43-036949C911C4}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "seqcli", "seqcli", "{7F7CAC3A-1046-4D2B-BF9F-F14525918295}"
ProjectSection(SolutionItems) = preProject
dockerfiles\seqcli\.gitignore = dockerfiles\seqcli\.gitignore
dockerfiles\seqcli\Dockerfile = dockerfiles\seqcli\Dockerfile
dockerfiles\seqcli\run.sh = dockerfiles\seqcli\run.sh
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Expand All@@ -50,9 +58,6 @@ Global
{DBC69360-519B-4A9B-829B-2AE1B5412521}.Debug|x64.Build.0 = Debug|x64
{DBC69360-519B-4A9B-829B-2AE1B5412521}.Release|x64.ActiveCfg = Release|x64
{DBC69360-519B-4A9B-829B-2AE1B5412521}.Release|x64.Build.0 = Release|x64
{5E28D963-3523-49DE-B03B-E76684258415}.Debug|x64.ActiveCfg = Debug|x64
{5E28D963-3523-49DE-B03B-E76684258415}.Release|x64.ActiveCfg = Release|x64
{5E28D963-3523-49DE-B03B-E76684258415}.Release|x64.Build.0 = Release|x64
{B86DEF3C-C461-4126-AD49-986EBB19B487}.Debug|x64.ActiveCfg = Debug|x64
{B86DEF3C-C461-4126-AD49-986EBB19B487}.Debug|x64.Build.0 = Debug|x64
{B86DEF3C-C461-4126-AD49-986EBB19B487}.Release|x64.ActiveCfg = Release|x64
Expand All@@ -64,8 +69,8 @@ Global
GlobalSection(NestedProjects) = preSolution
{EBDBEED2-A1BC-4269-B6B0-EA908CE4D687} = {FC0A256C-CC1F-4ECE-AF09-707248D10DC1}
{DBC69360-519B-4A9B-829B-2AE1B5412521} = {3587B633-0C03-4235-8903-6226900328F1}
{5E28D963-3523-49DE-B03B-E76684258415} = {203E8AE7-ADF0-44FA-A341-90723C8595F7}
{B86DEF3C-C461-4126-AD49-986EBB19B487} = {3587B633-0C03-4235-8903-6226900328F1}
{7F7CAC3A-1046-4D2B-BF9F-F14525918295} = {0779824B-502D-450B-BB43-036949C911C4}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6D299713-28D4-4078-9DA7-9033679CD200}
Expand Down
10 changes: 5 additions & 5 deletions src/SeqCli/Cli/Commands/ApiKey/CreateCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,7 +17,7 @@
using System.Threading.Tasks;
using Seq.Api.Model.Inputs;
using Seq.Api.Model.LogEvents;
using Seq.Api.Model.Signals;
using Seq.Api.Model.Shared;
using SeqCli.Cli.Features;
using SeqCli.Config;
using SeqCli.Connection;
Expand DownExpand Up@@ -82,17 +82,17 @@ protected override async Task<int> Run()
var apiKey = await connection.ApiKeys.TemplateAsync();

apiKey.Title = _title;
apiKey.AppliedProperties = _properties.Properties
apiKey.InputSettings.AppliedProperties = _properties.Properties
.Select(kvp => new InputAppliedPropertyPart {Name = kvp.Key, Value = kvp.Value})
.ToList();
apiKey.UseServerTimestamps = _useServerTimestamps;
apiKey.InputSettings.UseServerTimestamps = _useServerTimestamps;

// If _token is null, a value will be returned when the key is created
apiKey.Token = _token;

if (_filter != null)
{
apiKey.InputFilter = new SignalFilterPart
apiKey.InputSettings.Filter = new DescriptiveFilterPart
{
Filter = (await connection.Expressions.ToStrictAsync(_filter)).StrictExpression,
FilterNonStrict = _filter
Expand All@@ -101,7 +101,7 @@ protected override async Task<int> Run()

if (_level != null)
{
apiKey.MinimumLevel = Enum.Parse<LogEventLevel>(LevelMapping.ToFullLevelName(_level));
apiKey.InputSettings.MinimumLevel = Enum.Parse<LogEventLevel>(LevelMapping.ToFullLevelName(_level));
}

apiKey = await connection.ApiKeys.AddAsync(apiKey);
Expand Down
7 changes: 4 additions & 3 deletions src/SeqCli/Cli/Commands/Dashboard/RenderCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,9 +39,9 @@ class RenderCommand : Command
readonly ConnectionFeature _connection;
readonly OutputFormatFeature _output;
readonly SignalExpressionFeature _signal;
readonly TimeoutFeature _timeout;

string _id, _lastDuration, _intervalDuration, _chartTitle;
int? _timeoutMS;

public RenderCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config)
{
Expand All@@ -62,7 +62,7 @@ public RenderCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config
v => _intervalDuration = ArgumentString.Normalize(v));
_range = Enable<DateRangeFeature>();
_signal = Enable<SignalExpressionFeature>();
Options.Add("timeout=", "The query execution timeout in milliseconds", v => _timeoutMS = int.Parse(v?.Trim() ?? "0"));
_timeout = Enable<TimeoutFeature>();
_output = Enable(new OutputFormatFeature(config.Output));
_connection = Enable<ConnectionFeature>();
}
Expand DownExpand Up@@ -158,7 +158,8 @@ protected override async Task<int> Run()

var q = BuildSqlQuery(query, rangeStart, rangeEnd, timeGrouping);

var timeout = _timeoutMS.HasValue ? TimeSpan.FromMilliseconds(_timeoutMS.Value) : (TimeSpan?)null;
var timeout = _timeout.ApplyTimeout(connection.Client.HttpClient);

if (_output.Json)
{
var result = await connection.Data.QueryAsync(q, signal: signal, timeout: timeout);
Expand Down
6 changes: 5 additions & 1 deletion src/SeqCli/Cli/Commands/HelpCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -96,7 +96,11 @@ void PrintMarkdownHelp(string executableName)
{
if (cmd.Count() == 1)
{
Console.WriteLine($" - [`{cmd.Key}`](#{cmd.Key}) &mdash; {cmd.Single().Metadata.HelpText}.");
var single = cmd.Single();
if (single.Metadata.SubCommand == null)
Console.WriteLine($" - [`{cmd.Key}`](#{cmd.Key}) &mdash; {single.Metadata.HelpText}.");
else
Console.WriteLine($" - [`{cmd.Key} {single.Metadata.SubCommand}`](#{cmd.Key}-{single.Metadata.SubCommand}) &mdash; {single.Metadata.HelpText}.");
}
else
{
Expand Down
16 changes: 6 additions & 10 deletions src/SeqCli/Cli/Commands/QueryCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,6 +20,8 @@
using SeqCli.Connection;
using Serilog;

// ReSharper disable UnusedType.Global

namespace SeqCli.Cli.Commands
{
[Command("query", "Execute an SQL query and receive results in CSV format",
Expand All@@ -31,8 +33,8 @@ class QueryCommand : Command
readonly ConnectionFeature _connection;
readonly DateRangeFeature _range;
readonly SignalExpressionFeature _signal;
readonly TimeoutFeature _timeout;
string _query;
int? _timeoutMS;

public QueryCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config)
{
Expand All@@ -41,7 +43,7 @@ public QueryCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config)
Options.Add("q=|query=", "The query to execute", v => _query = v);
_range = Enable<DateRangeFeature>();
_signal = Enable<SignalExpressionFeature>();
Options.Add("timeout=", "The query execution timeout in milliseconds", v => _timeoutMS = int.Parse(v?.Trim() ?? "0"));
_timeout = Enable<TimeoutFeature>();
_output = Enable(new OutputFormatFeature(config.Output));
_connection = Enable<ConnectionFeature>();
}
Expand All@@ -55,15 +57,9 @@ protected override async Task<int> Run()
}

var connection = _connectionFactory.Connect(_connection);

var timeout = _timeoutMS.HasValue ? TimeSpan.FromMilliseconds(_timeoutMS.Value) : (TimeSpan?)null;
if (timeout != null)
{
// The timeout is applied server-side; allowing an extra 10 seconds here means that the
// user experience will be consistent - the error message will be the server's message, etc.
connection.Client.HttpClient.Timeout = timeout.Value.Add(TimeSpan.FromSeconds(10));
}

var timeout = _timeout.ApplyTimeout(connection.Client.HttpClient);

if (_output.Json)
{
var result = await connection.Data.QueryAsync(_query, _range.Start, _range.End, _signal.Signal, timeout: timeout);
Expand Down
3 changes: 2 additions & 1 deletion src/SeqCli/Cli/Commands/Signal/CreateCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,7 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Seq.Api.Model.Shared;
using Seq.Api.Model.Signals;
using SeqCli.Cli.Features;
using SeqCli.Config;
Expand DownExpand Up@@ -101,7 +102,7 @@ protected override async Task<int> Run()
{
signal.Filters = new[]
{
new SignalFilterPart
new DescriptiveFilterPart
{
Filter = (await connection.Expressions.ToStrictAsync(_filter)).StrictExpression,
FilterNonStrict = _filter
Expand Down
2 changes: 1 addition & 1 deletion src/SeqCli/Cli/Commands/Signal/ImportCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -69,7 +69,7 @@ protected override async Task<int> Run()
dest.Grouping = src.Grouping;
dest.IsProtected = src.IsProtected;
dest.Filters = src.Filters;
dest.TaggedProperties = src.TaggedProperties;
dest.Columns = src.Columns;
dest.OwnerId = _entityOwner.OwnerId;
await connection.Signals.AddAsync(dest);
}
Expand Down
3 changes: 2 additions & 1 deletion src/SeqCli/Cli/Commands/User/CreateCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,7 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Seq.Api.Model.Shared;
using Seq.Api.Model.Signals;
using SeqCli.Cli.Features;
using SeqCli.Config;
Expand DownExpand Up@@ -128,7 +129,7 @@ protected override async Task<int> Run()

if (_filter != null)
{
user.ViewFilter = new SignalFilterPart
user.ViewFilter = new DescriptiveFilterPart
{
Filter = (await connection.Expressions.ToStrictAsync(_filter)).StrictExpression,
FilterNonStrict = _filter
Expand Down
46 changes: 46 additions & 0 deletions src/SeqCli/Cli/Features/TimeoutFeature.cs
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
// Copyright Datalust Pty Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Net.Http;

namespace SeqCli.Cli.Features
{
class TimeoutFeature: CommandFeature
{
int? _timeoutMS;

public override void Enable(OptionSet options)
{
options.Add("timeout=", "The execution timeout in milliseconds", v => _timeoutMS = int.Parse(v?.Trim() ?? "0"));
}

// Ensures we don't forget to configure the client whenever the server is given a longer timeout than
// the client's internal default.
public TimeSpan? ApplyTimeout(HttpClient httpClient)
{
if (httpClient == null) throw new ArgumentNullException(nameof(httpClient));

var timeout = _timeoutMS.HasValue ? TimeSpan.FromMilliseconds(_timeoutMS.Value) : (TimeSpan?)null;
if (timeout != null)
{
// The timeout is applied server-side; allowing an extra 10 seconds here means that the
// user experience will be consistent - the error message will be the server's message, etc.
httpClient.Timeout = timeout.Value.Add(TimeSpan.FromSeconds(10));
}

return timeout;
}
}
}
6 changes: 3 additions & 3 deletions src/SeqCli/SeqCli.csproj
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp2.2</TargetFrameworks>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AssemblyName>seqcli</AssemblyName>
<ApplicationIcon>..\..\asset\SeqCli.ico</ApplicationIcon>
<RuntimeIdentifiers>win-x64;linux-x64;osx-x64</RuntimeIdentifiers>
<GenerateAssemblyInformationalVersionAttribute>True</GenerateAssemblyInformationalVersionAttribute>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<TreatSpecificWarningsAsErrors />
<Platforms>x64</Platforms>
<LangVersion>7.3</LangVersion>
<LangVersion>8</LangVersion>
</PropertyGroup>
<Import Project="..\..\SeqCli.Runtime.targets" />
<ItemGroup>
Expand All@@ -30,7 +30,7 @@
<PackageReference Include="Superpower" Version="2.3.0" />
<PackageReference Include="System.Reactive" Version="4.3.1" />
<PackageReference Include="System.Security.Cryptography.ProtectedData" Version="4.7.0" />
<PackageReference Include="Seq.Api" Version="5.1.2-*" />
<PackageReference Include="Seq.Api" Version="2020.1.0" />
<PackageReference Include="Seq.Apps" Version="5.1.0" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions test/SeqCli.EndToEnd/SeqCli.EndToEnd.csproj
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,9 +2,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp2.2</TargetFrameworks>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Platforms>x64</Platforms>
<LangVersion>7.3</LangVersion>
<LangVersion>8</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Autofac" Version="4.9.4" />
Expand Down
7 changes: 2 additions & 5 deletions test/SeqCli.Tests/Cli/NoDuplicateCommands.cs
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq;
using System.Reflection;
using System.Text;
using SeqCli.Cli;
using Xunit;

Expand All@@ -20,7 +17,7 @@ public void EnsureNoDuplicateCommands()
.GroupBy(t => new {t.Attribute.Name, t.Attribute.SubCommand})
.Any(t => t.Count() > 1);

Assert.Equal(anyDuplicates, false);
Assert.False(anyDuplicates);
}
}
}
1 change: 0 additions & 1 deletion test/SeqCli.Tests/PlainText/FrameReaderTests.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,6 @@
using System.IO;
using System.Text;
using System.Threading.Tasks;
using SeqCli.PlainText;
using SeqCli.PlainText.Framing;
using SeqCli.PlainText.Parsers;
using Superpower;
Expand Down
3 changes: 2 additions & 1 deletion test/SeqCli.Tests/SeqCli.Tests.csproj
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Platforms>x64</Platforms>
<LangVersion>8</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
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
2 changes: 1 addition & 1 deletion Build.Docker.ps1
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,7 @@ $IsCIBuild = $null -ne $env:APPVEYOR_BUILD_NUMBER
$IsPublishedBuild = ($env:APPVEYOR_REPO_BRANCH -eq "master" -or $env:APPVEYOR_REPO_BRANCH -eq "dev") -and $null -eq $env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH

$version = @{ $true = $env:APPVEYOR_BUILD_VERSION; $false = "99.99.99" }[$env:APPVEYOR_BUILD_VERSION -ne $NULL];
$framework = "netcoreapp2.2"
$framework = "netcoreapp3.1"
$rid = "linux-x64"
$tag = "datalust/seqcli-ci:$version"

Expand Down
2 changes: 1 addition & 1 deletion Build.ps1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
$ErrorActionPreference = 'Stop'

$framework = 'netcoreapp2.2'
$framework = 'netcoreapp3.1'

function Clean-Output
{
Expand Down
195 changes: 141 additions & 54 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion appveyor.yml
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
version: 5.1.{build}
version: 2020.1.{build}
skip_tags: true
image:
- Visual Studio 2019
Expand Down
2 changes: 1 addition & 1 deletion dockerfiles/seqcli/Dockerfile
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,7 +17,7 @@ RUN apt-get update \
&& rm -rf /var/lib/apt/lists/*

COPY dockerfiles/seqcli/run.sh /run.sh
COPY src/SeqCli/bin/Release/netcoreapp2.2/linux-x64/publish /bin/seqcli
COPY src/SeqCli/bin/Release/netcoreapp3.1/linux-x64/publish /bin/seqcli

ENTRYPOINT ["/run.sh"]

Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "2.2.105"
"version": "3.1.201"
}
}
21 changes: 13 additions & 8 deletions seqcli.sln
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,12 +14,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sln", "sln", "{2EA56595-519
LICENSE = LICENSE
README.md = README.md
SeqCli.Runtime.targets = SeqCli.Runtime.targets
setup.sh = setup.sh
Build.Docker.ps1 = Build.Docker.ps1
docker-publish.ps1 = docker-publish.ps1
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{3587B633-0C03-4235-8903-6226900328F1}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "setup", "setup", "{203E8AE7-ADF0-44FA-A341-90723C8595F7}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "asset", "asset", "{438A0DA5-F3CF-4FCE-B43A-B6DA2981D4AE}"
ProjectSection(SolutionItems) = preProject
asset\SeqCli-Icon-128px.ico = asset\SeqCli-Icon-128px.ico
Expand All@@ -32,10 +33,17 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SeqCli", "src\SeqCli\SeqCli
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SeqCli.Tests", "test\SeqCli.Tests\SeqCli.Tests.csproj", "{DBC69360-519B-4A9B-829B-2AE1B5412521}"
EndProject
Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "SeqCli.Setup", "setup\SeqCli.Setup\SeqCli.Setup.wixproj", "{5E28D963-3523-49DE-B03B-E76684258415}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SeqCli.EndToEnd", "test\SeqCli.EndToEnd\SeqCli.EndToEnd.csproj", "{B86DEF3C-C461-4126-AD49-986EBB19B487}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dockerfiles", "dockerfiles", "{0779824B-502D-450B-BB43-036949C911C4}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "seqcli", "seqcli", "{7F7CAC3A-1046-4D2B-BF9F-F14525918295}"
ProjectSection(SolutionItems) = preProject
dockerfiles\seqcli\.gitignore = dockerfiles\seqcli\.gitignore
dockerfiles\seqcli\Dockerfile = dockerfiles\seqcli\Dockerfile
dockerfiles\seqcli\run.sh = dockerfiles\seqcli\run.sh
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Expand All@@ -50,9 +58,6 @@ Global
{DBC69360-519B-4A9B-829B-2AE1B5412521}.Debug|x64.Build.0 = Debug|x64
{DBC69360-519B-4A9B-829B-2AE1B5412521}.Release|x64.ActiveCfg = Release|x64
{DBC69360-519B-4A9B-829B-2AE1B5412521}.Release|x64.Build.0 = Release|x64
{5E28D963-3523-49DE-B03B-E76684258415}.Debug|x64.ActiveCfg = Debug|x64
{5E28D963-3523-49DE-B03B-E76684258415}.Release|x64.ActiveCfg = Release|x64
{5E28D963-3523-49DE-B03B-E76684258415}.Release|x64.Build.0 = Release|x64
{B86DEF3C-C461-4126-AD49-986EBB19B487}.Debug|x64.ActiveCfg = Debug|x64
{B86DEF3C-C461-4126-AD49-986EBB19B487}.Debug|x64.Build.0 = Debug|x64
{B86DEF3C-C461-4126-AD49-986EBB19B487}.Release|x64.ActiveCfg = Release|x64
Expand All@@ -64,8 +69,8 @@ Global
GlobalSection(NestedProjects) = preSolution
{EBDBEED2-A1BC-4269-B6B0-EA908CE4D687} = {FC0A256C-CC1F-4ECE-AF09-707248D10DC1}
{DBC69360-519B-4A9B-829B-2AE1B5412521} = {3587B633-0C03-4235-8903-6226900328F1}
{5E28D963-3523-49DE-B03B-E76684258415} = {203E8AE7-ADF0-44FA-A341-90723C8595F7}
{B86DEF3C-C461-4126-AD49-986EBB19B487} = {3587B633-0C03-4235-8903-6226900328F1}
{7F7CAC3A-1046-4D2B-BF9F-F14525918295} = {0779824B-502D-450B-BB43-036949C911C4}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6D299713-28D4-4078-9DA7-9033679CD200}
Expand Down
10 changes: 5 additions & 5 deletions src/SeqCli/Cli/Commands/ApiKey/CreateCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,7 +17,7 @@
using System.Threading.Tasks;
using Seq.Api.Model.Inputs;
using Seq.Api.Model.LogEvents;
using Seq.Api.Model.Signals;
using Seq.Api.Model.Shared;
using SeqCli.Cli.Features;
using SeqCli.Config;
using SeqCli.Connection;
Expand DownExpand Up@@ -82,17 +82,17 @@ protected override async Task<int> Run()
var apiKey = await connection.ApiKeys.TemplateAsync();

apiKey.Title = _title;
apiKey.AppliedProperties = _properties.Properties
apiKey.InputSettings.AppliedProperties = _properties.Properties
.Select(kvp => new InputAppliedPropertyPart {Name = kvp.Key, Value = kvp.Value})
.ToList();
apiKey.UseServerTimestamps = _useServerTimestamps;
apiKey.InputSettings.UseServerTimestamps = _useServerTimestamps;

// If _token is null, a value will be returned when the key is created
apiKey.Token = _token;

if (_filter != null)
{
apiKey.InputFilter = new SignalFilterPart
apiKey.InputSettings.Filter = new DescriptiveFilterPart
{
Filter = (await connection.Expressions.ToStrictAsync(_filter)).StrictExpression,
FilterNonStrict = _filter
Expand All@@ -101,7 +101,7 @@ protected override async Task<int> Run()

if (_level != null)
{
apiKey.MinimumLevel = Enum.Parse<LogEventLevel>(LevelMapping.ToFullLevelName(_level));
apiKey.InputSettings.MinimumLevel = Enum.Parse<LogEventLevel>(LevelMapping.ToFullLevelName(_level));
}

apiKey = await connection.ApiKeys.AddAsync(apiKey);
Expand Down
7 changes: 4 additions & 3 deletions src/SeqCli/Cli/Commands/Dashboard/RenderCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,9 +39,9 @@ class RenderCommand : Command
readonly ConnectionFeature _connection;
readonly OutputFormatFeature _output;
readonly SignalExpressionFeature _signal;
readonly TimeoutFeature _timeout;

string _id, _lastDuration, _intervalDuration, _chartTitle;
int? _timeoutMS;

public RenderCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config)
{
Expand All@@ -62,7 +62,7 @@ public RenderCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config
v => _intervalDuration = ArgumentString.Normalize(v));
_range = Enable<DateRangeFeature>();
_signal = Enable<SignalExpressionFeature>();
Options.Add("timeout=", "The query execution timeout in milliseconds", v => _timeoutMS = int.Parse(v?.Trim() ?? "0"));
_timeout = Enable<TimeoutFeature>();
_output = Enable(new OutputFormatFeature(config.Output));
_connection = Enable<ConnectionFeature>();
}
Expand DownExpand Up@@ -158,7 +158,8 @@ protected override async Task<int> Run()

var q = BuildSqlQuery(query, rangeStart, rangeEnd, timeGrouping);

var timeout = _timeoutMS.HasValue ? TimeSpan.FromMilliseconds(_timeoutMS.Value) : (TimeSpan?)null;
var timeout = _timeout.ApplyTimeout(connection.Client.HttpClient);

if (_output.Json)
{
var result = await connection.Data.QueryAsync(q, signal: signal, timeout: timeout);
Expand Down
6 changes: 5 additions & 1 deletion src/SeqCli/Cli/Commands/HelpCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -96,7 +96,11 @@ void PrintMarkdownHelp(string executableName)
{
if (cmd.Count() == 1)
{
Console.WriteLine($" - [`{cmd.Key}`](#{cmd.Key}) &mdash; {cmd.Single().Metadata.HelpText}.");
var single = cmd.Single();
if (single.Metadata.SubCommand == null)
Console.WriteLine($" - [`{cmd.Key}`](#{cmd.Key}) &mdash; {single.Metadata.HelpText}.");
else
Console.WriteLine($" - [`{cmd.Key} {single.Metadata.SubCommand}`](#{cmd.Key}-{single.Metadata.SubCommand}) &mdash; {single.Metadata.HelpText}.");
}
else
{
Expand Down
16 changes: 6 additions & 10 deletions src/SeqCli/Cli/Commands/QueryCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,6 +20,8 @@
using SeqCli.Connection;
using Serilog;

// ReSharper disable UnusedType.Global

namespace SeqCli.Cli.Commands
{
[Command("query", "Execute an SQL query and receive results in CSV format",
Expand All@@ -31,8 +33,8 @@ class QueryCommand : Command
readonly ConnectionFeature _connection;
readonly DateRangeFeature _range;
readonly SignalExpressionFeature _signal;
readonly TimeoutFeature _timeout;
string _query;
int? _timeoutMS;

public QueryCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config)
{
Expand All@@ -41,7 +43,7 @@ public QueryCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config)
Options.Add("q=|query=", "The query to execute", v => _query = v);
_range = Enable<DateRangeFeature>();
_signal = Enable<SignalExpressionFeature>();
Options.Add("timeout=", "The query execution timeout in milliseconds", v => _timeoutMS = int.Parse(v?.Trim() ?? "0"));
_timeout = Enable<TimeoutFeature>();
_output = Enable(new OutputFormatFeature(config.Output));
_connection = Enable<ConnectionFeature>();
}
Expand All@@ -55,15 +57,9 @@ protected override async Task<int> Run()
}

var connection = _connectionFactory.Connect(_connection);

var timeout = _timeoutMS.HasValue ? TimeSpan.FromMilliseconds(_timeoutMS.Value) : (TimeSpan?)null;
if (timeout != null)
{
// The timeout is applied server-side; allowing an extra 10 seconds here means that the
// user experience will be consistent - the error message will be the server's message, etc.
connection.Client.HttpClient.Timeout = timeout.Value.Add(TimeSpan.FromSeconds(10));
}

var timeout = _timeout.ApplyTimeout(connection.Client.HttpClient);

if (_output.Json)
{
var result = await connection.Data.QueryAsync(_query, _range.Start, _range.End, _signal.Signal, timeout: timeout);
Expand Down
3 changes: 2 additions & 1 deletion src/SeqCli/Cli/Commands/Signal/CreateCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,7 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Seq.Api.Model.Shared;
using Seq.Api.Model.Signals;
using SeqCli.Cli.Features;
using SeqCli.Config;
Expand DownExpand Up@@ -101,7 +102,7 @@ protected override async Task<int> Run()
{
signal.Filters = new[]
{
new SignalFilterPart
new DescriptiveFilterPart
{
Filter = (await connection.Expressions.ToStrictAsync(_filter)).StrictExpression,
FilterNonStrict = _filter
Expand Down
2 changes: 1 addition & 1 deletion src/SeqCli/Cli/Commands/Signal/ImportCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -69,7 +69,7 @@ protected override async Task<int> Run()
dest.Grouping = src.Grouping;
dest.IsProtected = src.IsProtected;
dest.Filters = src.Filters;
dest.TaggedProperties = src.TaggedProperties;
dest.Columns = src.Columns;
dest.OwnerId = _entityOwner.OwnerId;
await connection.Signals.AddAsync(dest);
}
Expand Down
3 changes: 2 additions & 1 deletion src/SeqCli/Cli/Commands/User/CreateCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,7 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Seq.Api.Model.Shared;
using Seq.Api.Model.Signals;
using SeqCli.Cli.Features;
using SeqCli.Config;
Expand DownExpand Up@@ -128,7 +129,7 @@ protected override async Task<int> Run()

if (_filter != null)
{
user.ViewFilter = new SignalFilterPart
user.ViewFilter = new DescriptiveFilterPart
{
Filter = (await connection.Expressions.ToStrictAsync(_filter)).StrictExpression,
FilterNonStrict = _filter
Expand Down
46 changes: 46 additions & 0 deletions src/SeqCli/Cli/Features/TimeoutFeature.cs
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
// Copyright Datalust Pty Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Net.Http;

namespace SeqCli.Cli.Features
{
class TimeoutFeature: CommandFeature
{
int? _timeoutMS;

public override void Enable(OptionSet options)
{
options.Add("timeout=", "The execution timeout in milliseconds", v => _timeoutMS = int.Parse(v?.Trim() ?? "0"));
}

// Ensures we don't forget to configure the client whenever the server is given a longer timeout than
// the client's internal default.
public TimeSpan? ApplyTimeout(HttpClient httpClient)
{
if (httpClient == null) throw new ArgumentNullException(nameof(httpClient));

var timeout = _timeoutMS.HasValue ? TimeSpan.FromMilliseconds(_timeoutMS.Value) : (TimeSpan?)null;
if (timeout != null)
{
// The timeout is applied server-side; allowing an extra 10 seconds here means that the
// user experience will be consistent - the error message will be the server's message, etc.
httpClient.Timeout = timeout.Value.Add(TimeSpan.FromSeconds(10));
}

return timeout;
}
}
}
6 changes: 3 additions & 3 deletions src/SeqCli/SeqCli.csproj
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp2.2</TargetFrameworks>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AssemblyName>seqcli</AssemblyName>
<ApplicationIcon>..\..\asset\SeqCli.ico</ApplicationIcon>
<RuntimeIdentifiers>win-x64;linux-x64;osx-x64</RuntimeIdentifiers>
<GenerateAssemblyInformationalVersionAttribute>True</GenerateAssemblyInformationalVersionAttribute>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<TreatSpecificWarningsAsErrors />
<Platforms>x64</Platforms>
<LangVersion>7.3</LangVersion>
<LangVersion>8</LangVersion>
</PropertyGroup>
<Import Project="..\..\SeqCli.Runtime.targets" />
<ItemGroup>
Expand All@@ -30,7 +30,7 @@
<PackageReference Include="Superpower" Version="2.3.0" />
<PackageReference Include="System.Reactive" Version="4.3.1" />
<PackageReference Include="System.Security.Cryptography.ProtectedData" Version="4.7.0" />
<PackageReference Include="Seq.Api" Version="5.1.2-*" />
<PackageReference Include="Seq.Api" Version="2020.1.0" />
<PackageReference Include="Seq.Apps" Version="5.1.0" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions test/SeqCli.EndToEnd/SeqCli.EndToEnd.csproj
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,9 +2,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp2.2</TargetFrameworks>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Platforms>x64</Platforms>
<LangVersion>7.3</LangVersion>
<LangVersion>8</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Autofac" Version="4.9.4" />
Expand Down
7 changes: 2 additions & 5 deletions test/SeqCli.Tests/Cli/NoDuplicateCommands.cs
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq;
using System.Reflection;
using System.Text;
using SeqCli.Cli;
using Xunit;

Expand All@@ -20,7 +17,7 @@ public void EnsureNoDuplicateCommands()
.GroupBy(t => new {t.Attribute.Name, t.Attribute.SubCommand})
.Any(t => t.Count() > 1);

Assert.Equal(anyDuplicates, false);
Assert.False(anyDuplicates);
}
}
}
1 change: 0 additions & 1 deletion test/SeqCli.Tests/PlainText/FrameReaderTests.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,6 @@
using System.IO;
using System.Text;
using System.Threading.Tasks;
using SeqCli.PlainText;
using SeqCli.PlainText.Framing;
using SeqCli.PlainText.Parsers;
using Superpower;
Expand Down
3 changes: 2 additions & 1 deletion test/SeqCli.Tests/SeqCli.Tests.csproj
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Platforms>x64</Platforms>
<LangVersion>8</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content
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
2 changes: 1 addition & 1 deletion Build.Docker.ps1
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,7 @@ $IsCIBuild = $null -ne $env:APPVEYOR_BUILD_NUMBER
$IsPublishedBuild = ($env:APPVEYOR_REPO_BRANCH -eq "master" -or $env:APPVEYOR_REPO_BRANCH -eq "dev") -and $null -eq $env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH

$version = @{ $true = $env:APPVEYOR_BUILD_VERSION; $false = "99.99.99" }[$env:APPVEYOR_BUILD_VERSION -ne $NULL];
$framework = "netcoreapp2.2"
$framework = "netcoreapp3.1"
$rid = "linux-x64"
$tag = "datalust/seqcli-ci:$version"

Expand Down
2 changes: 1 addition & 1 deletion Build.ps1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
$ErrorActionPreference = 'Stop'

$framework = 'netcoreapp2.2'
$framework = 'netcoreapp3.1'

function Clean-Output
{
Expand Down
195 changes: 141 additions & 54 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion appveyor.yml
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
version: 5.1.{build}
version: 2020.1.{build}
skip_tags: true
image:
- Visual Studio 2019
Expand Down
2 changes: 1 addition & 1 deletion dockerfiles/seqcli/Dockerfile
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,7 +17,7 @@ RUN apt-get update \
&& rm -rf /var/lib/apt/lists/*

COPY dockerfiles/seqcli/run.sh /run.sh
COPY src/SeqCli/bin/Release/netcoreapp2.2/linux-x64/publish /bin/seqcli
COPY src/SeqCli/bin/Release/netcoreapp3.1/linux-x64/publish /bin/seqcli

ENTRYPOINT ["/run.sh"]

Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "2.2.105"
"version": "3.1.201"
}
}
21 changes: 13 additions & 8 deletions seqcli.sln
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,12 +14,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sln", "sln", "{2EA56595-519
LICENSE = LICENSE
README.md = README.md
SeqCli.Runtime.targets = SeqCli.Runtime.targets
setup.sh = setup.sh
Build.Docker.ps1 = Build.Docker.ps1
docker-publish.ps1 = docker-publish.ps1
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{3587B633-0C03-4235-8903-6226900328F1}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "setup", "setup", "{203E8AE7-ADF0-44FA-A341-90723C8595F7}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "asset", "asset", "{438A0DA5-F3CF-4FCE-B43A-B6DA2981D4AE}"
ProjectSection(SolutionItems) = preProject
asset\SeqCli-Icon-128px.ico = asset\SeqCli-Icon-128px.ico
Expand All@@ -32,10 +33,17 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SeqCli", "src\SeqCli\SeqCli
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SeqCli.Tests", "test\SeqCli.Tests\SeqCli.Tests.csproj", "{DBC69360-519B-4A9B-829B-2AE1B5412521}"
EndProject
Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "SeqCli.Setup", "setup\SeqCli.Setup\SeqCli.Setup.wixproj", "{5E28D963-3523-49DE-B03B-E76684258415}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SeqCli.EndToEnd", "test\SeqCli.EndToEnd\SeqCli.EndToEnd.csproj", "{B86DEF3C-C461-4126-AD49-986EBB19B487}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dockerfiles", "dockerfiles", "{0779824B-502D-450B-BB43-036949C911C4}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "seqcli", "seqcli", "{7F7CAC3A-1046-4D2B-BF9F-F14525918295}"
ProjectSection(SolutionItems) = preProject
dockerfiles\seqcli\.gitignore = dockerfiles\seqcli\.gitignore
dockerfiles\seqcli\Dockerfile = dockerfiles\seqcli\Dockerfile
dockerfiles\seqcli\run.sh = dockerfiles\seqcli\run.sh
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Expand All@@ -50,9 +58,6 @@ Global
{DBC69360-519B-4A9B-829B-2AE1B5412521}.Debug|x64.Build.0 = Debug|x64
{DBC69360-519B-4A9B-829B-2AE1B5412521}.Release|x64.ActiveCfg = Release|x64
{DBC69360-519B-4A9B-829B-2AE1B5412521}.Release|x64.Build.0 = Release|x64
{5E28D963-3523-49DE-B03B-E76684258415}.Debug|x64.ActiveCfg = Debug|x64
{5E28D963-3523-49DE-B03B-E76684258415}.Release|x64.ActiveCfg = Release|x64
{5E28D963-3523-49DE-B03B-E76684258415}.Release|x64.Build.0 = Release|x64
{B86DEF3C-C461-4126-AD49-986EBB19B487}.Debug|x64.ActiveCfg = Debug|x64
{B86DEF3C-C461-4126-AD49-986EBB19B487}.Debug|x64.Build.0 = Debug|x64
{B86DEF3C-C461-4126-AD49-986EBB19B487}.Release|x64.ActiveCfg = Release|x64
Expand All@@ -64,8 +69,8 @@ Global
GlobalSection(NestedProjects) = preSolution
{EBDBEED2-A1BC-4269-B6B0-EA908CE4D687} = {FC0A256C-CC1F-4ECE-AF09-707248D10DC1}
{DBC69360-519B-4A9B-829B-2AE1B5412521} = {3587B633-0C03-4235-8903-6226900328F1}
{5E28D963-3523-49DE-B03B-E76684258415} = {203E8AE7-ADF0-44FA-A341-90723C8595F7}
{B86DEF3C-C461-4126-AD49-986EBB19B487} = {3587B633-0C03-4235-8903-6226900328F1}
{7F7CAC3A-1046-4D2B-BF9F-F14525918295} = {0779824B-502D-450B-BB43-036949C911C4}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6D299713-28D4-4078-9DA7-9033679CD200}
Expand Down
10 changes: 5 additions & 5 deletions src/SeqCli/Cli/Commands/ApiKey/CreateCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,7 +17,7 @@
using System.Threading.Tasks;
using Seq.Api.Model.Inputs;
using Seq.Api.Model.LogEvents;
using Seq.Api.Model.Signals;
using Seq.Api.Model.Shared;
using SeqCli.Cli.Features;
using SeqCli.Config;
using SeqCli.Connection;
Expand DownExpand Up@@ -82,17 +82,17 @@ protected override async Task<int> Run()
var apiKey = await connection.ApiKeys.TemplateAsync();

apiKey.Title = _title;
apiKey.AppliedProperties = _properties.Properties
apiKey.InputSettings.AppliedProperties = _properties.Properties
.Select(kvp => new InputAppliedPropertyPart {Name = kvp.Key, Value = kvp.Value})
.ToList();
apiKey.UseServerTimestamps = _useServerTimestamps;
apiKey.InputSettings.UseServerTimestamps = _useServerTimestamps;

// If _token is null, a value will be returned when the key is created
apiKey.Token = _token;

if (_filter != null)
{
apiKey.InputFilter = new SignalFilterPart
apiKey.InputSettings.Filter = new DescriptiveFilterPart
{
Filter = (await connection.Expressions.ToStrictAsync(_filter)).StrictExpression,
FilterNonStrict = _filter
Expand All@@ -101,7 +101,7 @@ protected override async Task<int> Run()

if (_level != null)
{
apiKey.MinimumLevel = Enum.Parse<LogEventLevel>(LevelMapping.ToFullLevelName(_level));
apiKey.InputSettings.MinimumLevel = Enum.Parse<LogEventLevel>(LevelMapping.ToFullLevelName(_level));
}

apiKey = await connection.ApiKeys.AddAsync(apiKey);
Expand Down
7 changes: 4 additions & 3 deletions src/SeqCli/Cli/Commands/Dashboard/RenderCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,9 +39,9 @@ class RenderCommand : Command
readonly ConnectionFeature _connection;
readonly OutputFormatFeature _output;
readonly SignalExpressionFeature _signal;
readonly TimeoutFeature _timeout;

string _id, _lastDuration, _intervalDuration, _chartTitle;
int? _timeoutMS;

public RenderCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config)
{
Expand All@@ -62,7 +62,7 @@ public RenderCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config
v => _intervalDuration = ArgumentString.Normalize(v));
_range = Enable<DateRangeFeature>();
_signal = Enable<SignalExpressionFeature>();
Options.Add("timeout=", "The query execution timeout in milliseconds", v => _timeoutMS = int.Parse(v?.Trim() ?? "0"));
_timeout = Enable<TimeoutFeature>();
_output = Enable(new OutputFormatFeature(config.Output));
_connection = Enable<ConnectionFeature>();
}
Expand DownExpand Up@@ -158,7 +158,8 @@ protected override async Task<int> Run()

var q = BuildSqlQuery(query, rangeStart, rangeEnd, timeGrouping);

var timeout = _timeoutMS.HasValue ? TimeSpan.FromMilliseconds(_timeoutMS.Value) : (TimeSpan?)null;
var timeout = _timeout.ApplyTimeout(connection.Client.HttpClient);

if (_output.Json)
{
var result = await connection.Data.QueryAsync(q, signal: signal, timeout: timeout);
Expand Down
6 changes: 5 additions & 1 deletion src/SeqCli/Cli/Commands/HelpCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -96,7 +96,11 @@ void PrintMarkdownHelp(string executableName)
{
if (cmd.Count() == 1)
{
Console.WriteLine($" - [`{cmd.Key}`](#{cmd.Key}) &mdash; {cmd.Single().Metadata.HelpText}.");
var single = cmd.Single();
if (single.Metadata.SubCommand == null)
Console.WriteLine($" - [`{cmd.Key}`](#{cmd.Key}) &mdash; {single.Metadata.HelpText}.");
else
Console.WriteLine($" - [`{cmd.Key} {single.Metadata.SubCommand}`](#{cmd.Key}-{single.Metadata.SubCommand}) &mdash; {single.Metadata.HelpText}.");
}
else
{
Expand Down
16 changes: 6 additions & 10 deletions src/SeqCli/Cli/Commands/QueryCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,6 +20,8 @@
using SeqCli.Connection;
using Serilog;

// ReSharper disable UnusedType.Global

namespace SeqCli.Cli.Commands
{
[Command("query", "Execute an SQL query and receive results in CSV format",
Expand All@@ -31,8 +33,8 @@ class QueryCommand : Command
readonly ConnectionFeature _connection;
readonly DateRangeFeature _range;
readonly SignalExpressionFeature _signal;
readonly TimeoutFeature _timeout;
string _query;
int? _timeoutMS;

public QueryCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config)
{
Expand All@@ -41,7 +43,7 @@ public QueryCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config)
Options.Add("q=|query=", "The query to execute", v => _query = v);
_range = Enable<DateRangeFeature>();
_signal = Enable<SignalExpressionFeature>();
Options.Add("timeout=", "The query execution timeout in milliseconds", v => _timeoutMS = int.Parse(v?.Trim() ?? "0"));
_timeout = Enable<TimeoutFeature>();
_output = Enable(new OutputFormatFeature(config.Output));
_connection = Enable<ConnectionFeature>();
}
Expand All@@ -55,15 +57,9 @@ protected override async Task<int> Run()
}

var connection = _connectionFactory.Connect(_connection);

var timeout = _timeoutMS.HasValue ? TimeSpan.FromMilliseconds(_timeoutMS.Value) : (TimeSpan?)null;
if (timeout != null)
{
// The timeout is applied server-side; allowing an extra 10 seconds here means that the
// user experience will be consistent - the error message will be the server's message, etc.
connection.Client.HttpClient.Timeout = timeout.Value.Add(TimeSpan.FromSeconds(10));
}

var timeout = _timeout.ApplyTimeout(connection.Client.HttpClient);

if (_output.Json)
{
var result = await connection.Data.QueryAsync(_query, _range.Start, _range.End, _signal.Signal, timeout: timeout);
Expand Down
3 changes: 2 additions & 1 deletion src/SeqCli/Cli/Commands/Signal/CreateCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,7 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Seq.Api.Model.Shared;
using Seq.Api.Model.Signals;
using SeqCli.Cli.Features;
using SeqCli.Config;
Expand DownExpand Up@@ -101,7 +102,7 @@ protected override async Task<int> Run()
{
signal.Filters = new[]
{
new SignalFilterPart
new DescriptiveFilterPart
{
Filter = (await connection.Expressions.ToStrictAsync(_filter)).StrictExpression,
FilterNonStrict = _filter
Expand Down
2 changes: 1 addition & 1 deletion src/SeqCli/Cli/Commands/Signal/ImportCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -69,7 +69,7 @@ protected override async Task<int> Run()
dest.Grouping = src.Grouping;
dest.IsProtected = src.IsProtected;
dest.Filters = src.Filters;
dest.TaggedProperties = src.TaggedProperties;
dest.Columns = src.Columns;
dest.OwnerId = _entityOwner.OwnerId;
await connection.Signals.AddAsync(dest);
}
Expand Down
3 changes: 2 additions & 1 deletion src/SeqCli/Cli/Commands/User/CreateCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,7 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Seq.Api.Model.Shared;
using Seq.Api.Model.Signals;
using SeqCli.Cli.Features;
using SeqCli.Config;
Expand DownExpand Up@@ -128,7 +129,7 @@ protected override async Task<int> Run()

if (_filter != null)
{
user.ViewFilter = new SignalFilterPart
user.ViewFilter = new DescriptiveFilterPart
{
Filter = (await connection.Expressions.ToStrictAsync(_filter)).StrictExpression,
FilterNonStrict = _filter
Expand Down
46 changes: 46 additions & 0 deletions src/SeqCli/Cli/Features/TimeoutFeature.cs
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
// Copyright Datalust Pty Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Net.Http;

namespace SeqCli.Cli.Features
{
class TimeoutFeature: CommandFeature
{
int? _timeoutMS;

public override void Enable(OptionSet options)
{
options.Add("timeout=", "The execution timeout in milliseconds", v => _timeoutMS = int.Parse(v?.Trim() ?? "0"));
}

// Ensures we don't forget to configure the client whenever the server is given a longer timeout than
// the client's internal default.
public TimeSpan? ApplyTimeout(HttpClient httpClient)
{
if (httpClient == null) throw new ArgumentNullException(nameof(httpClient));

var timeout = _timeoutMS.HasValue ? TimeSpan.FromMilliseconds(_timeoutMS.Value) : (TimeSpan?)null;
if (timeout != null)
{
// The timeout is applied server-side; allowing an extra 10 seconds here means that the
// user experience will be consistent - the error message will be the server's message, etc.
httpClient.Timeout = timeout.Value.Add(TimeSpan.FromSeconds(10));
}

return timeout;
}
}
}
6 changes: 3 additions & 3 deletions src/SeqCli/SeqCli.csproj
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp2.2</TargetFrameworks>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AssemblyName>seqcli</AssemblyName>
<ApplicationIcon>..\..\asset\SeqCli.ico</ApplicationIcon>
<RuntimeIdentifiers>win-x64;linux-x64;osx-x64</RuntimeIdentifiers>
<GenerateAssemblyInformationalVersionAttribute>True</GenerateAssemblyInformationalVersionAttribute>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<TreatSpecificWarningsAsErrors />
<Platforms>x64</Platforms>
<LangVersion>7.3</LangVersion>
<LangVersion>8</LangVersion>
</PropertyGroup>
<Import Project="..\..\SeqCli.Runtime.targets" />
<ItemGroup>
Expand All@@ -30,7 +30,7 @@
<PackageReference Include="Superpower" Version="2.3.0" />
<PackageReference Include="System.Reactive" Version="4.3.1" />
<PackageReference Include="System.Security.Cryptography.ProtectedData" Version="4.7.0" />
<PackageReference Include="Seq.Api" Version="5.1.2-*" />
<PackageReference Include="Seq.Api" Version="2020.1.0" />
<PackageReference Include="Seq.Apps" Version="5.1.0" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions test/SeqCli.EndToEnd/SeqCli.EndToEnd.csproj
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,9 +2,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp2.2</TargetFrameworks>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Platforms>x64</Platforms>
<LangVersion>7.3</LangVersion>
<LangVersion>8</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Autofac" Version="4.9.4" />
Expand Down
7 changes: 2 additions & 5 deletions test/SeqCli.Tests/Cli/NoDuplicateCommands.cs
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq;
using System.Reflection;
using System.Text;
using SeqCli.Cli;
using Xunit;

Expand All@@ -20,7 +17,7 @@ public void EnsureNoDuplicateCommands()
.GroupBy(t => new {t.Attribute.Name, t.Attribute.SubCommand})
.Any(t => t.Count() > 1);

Assert.Equal(anyDuplicates, false);
Assert.False(anyDuplicates);
}
}
}
1 change: 0 additions & 1 deletion test/SeqCli.Tests/PlainText/FrameReaderTests.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,6 @@
using System.IO;
using System.Text;
using System.Threading.Tasks;
using SeqCli.PlainText;
using SeqCli.PlainText.Framing;
using SeqCli.PlainText.Parsers;
using Superpower;
Expand Down
3 changes: 2 additions & 1 deletion test/SeqCli.Tests/SeqCli.Tests.csproj
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Platforms>x64</Platforms>
<LangVersion>8</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
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
2 changes: 1 addition & 1 deletion Build.Docker.ps1
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,7 @@ $IsCIBuild = $null -ne $env:APPVEYOR_BUILD_NUMBER
$IsPublishedBuild = ($env:APPVEYOR_REPO_BRANCH -eq "master" -or $env:APPVEYOR_REPO_BRANCH -eq "dev") -and $null -eq $env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH

$version = @{ $true = $env:APPVEYOR_BUILD_VERSION; $false = "99.99.99" }[$env:APPVEYOR_BUILD_VERSION -ne $NULL];
$framework = "netcoreapp2.2"
$framework = "netcoreapp3.1"
$rid = "linux-x64"
$tag = "datalust/seqcli-ci:$version"

Expand Down
2 changes: 1 addition & 1 deletion Build.ps1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
$ErrorActionPreference = 'Stop'

$framework = 'netcoreapp2.2'
$framework = 'netcoreapp3.1'

function Clean-Output
{
Expand Down
195 changes: 141 additions & 54 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion appveyor.yml
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
version: 5.1.{build}
version: 2020.1.{build}
skip_tags: true
image:
- Visual Studio 2019
Expand Down
2 changes: 1 addition & 1 deletion dockerfiles/seqcli/Dockerfile
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,7 +17,7 @@ RUN apt-get update \
&& rm -rf /var/lib/apt/lists/*

COPY dockerfiles/seqcli/run.sh /run.sh
COPY src/SeqCli/bin/Release/netcoreapp2.2/linux-x64/publish /bin/seqcli
COPY src/SeqCli/bin/Release/netcoreapp3.1/linux-x64/publish /bin/seqcli

ENTRYPOINT ["/run.sh"]

Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "2.2.105"
"version": "3.1.201"
}
}
21 changes: 13 additions & 8 deletions seqcli.sln
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,12 +14,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sln", "sln", "{2EA56595-519
LICENSE = LICENSE
README.md = README.md
SeqCli.Runtime.targets = SeqCli.Runtime.targets
setup.sh = setup.sh
Build.Docker.ps1 = Build.Docker.ps1
docker-publish.ps1 = docker-publish.ps1
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{3587B633-0C03-4235-8903-6226900328F1}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "setup", "setup", "{203E8AE7-ADF0-44FA-A341-90723C8595F7}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "asset", "asset", "{438A0DA5-F3CF-4FCE-B43A-B6DA2981D4AE}"
ProjectSection(SolutionItems) = preProject
asset\SeqCli-Icon-128px.ico = asset\SeqCli-Icon-128px.ico
Expand All@@ -32,10 +33,17 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SeqCli", "src\SeqCli\SeqCli
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SeqCli.Tests", "test\SeqCli.Tests\SeqCli.Tests.csproj", "{DBC69360-519B-4A9B-829B-2AE1B5412521}"
EndProject
Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "SeqCli.Setup", "setup\SeqCli.Setup\SeqCli.Setup.wixproj", "{5E28D963-3523-49DE-B03B-E76684258415}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SeqCli.EndToEnd", "test\SeqCli.EndToEnd\SeqCli.EndToEnd.csproj", "{B86DEF3C-C461-4126-AD49-986EBB19B487}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dockerfiles", "dockerfiles", "{0779824B-502D-450B-BB43-036949C911C4}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "seqcli", "seqcli", "{7F7CAC3A-1046-4D2B-BF9F-F14525918295}"
ProjectSection(SolutionItems) = preProject
dockerfiles\seqcli\.gitignore = dockerfiles\seqcli\.gitignore
dockerfiles\seqcli\Dockerfile = dockerfiles\seqcli\Dockerfile
dockerfiles\seqcli\run.sh = dockerfiles\seqcli\run.sh
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Expand All@@ -50,9 +58,6 @@ Global
{DBC69360-519B-4A9B-829B-2AE1B5412521}.Debug|x64.Build.0 = Debug|x64
{DBC69360-519B-4A9B-829B-2AE1B5412521}.Release|x64.ActiveCfg = Release|x64
{DBC69360-519B-4A9B-829B-2AE1B5412521}.Release|x64.Build.0 = Release|x64
{5E28D963-3523-49DE-B03B-E76684258415}.Debug|x64.ActiveCfg = Debug|x64
{5E28D963-3523-49DE-B03B-E76684258415}.Release|x64.ActiveCfg = Release|x64
{5E28D963-3523-49DE-B03B-E76684258415}.Release|x64.Build.0 = Release|x64
{B86DEF3C-C461-4126-AD49-986EBB19B487}.Debug|x64.ActiveCfg = Debug|x64
{B86DEF3C-C461-4126-AD49-986EBB19B487}.Debug|x64.Build.0 = Debug|x64
{B86DEF3C-C461-4126-AD49-986EBB19B487}.Release|x64.ActiveCfg = Release|x64
Expand All@@ -64,8 +69,8 @@ Global
GlobalSection(NestedProjects) = preSolution
{EBDBEED2-A1BC-4269-B6B0-EA908CE4D687} = {FC0A256C-CC1F-4ECE-AF09-707248D10DC1}
{DBC69360-519B-4A9B-829B-2AE1B5412521} = {3587B633-0C03-4235-8903-6226900328F1}
{5E28D963-3523-49DE-B03B-E76684258415} = {203E8AE7-ADF0-44FA-A341-90723C8595F7}
{B86DEF3C-C461-4126-AD49-986EBB19B487} = {3587B633-0C03-4235-8903-6226900328F1}
{7F7CAC3A-1046-4D2B-BF9F-F14525918295} = {0779824B-502D-450B-BB43-036949C911C4}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6D299713-28D4-4078-9DA7-9033679CD200}
Expand Down
10 changes: 5 additions & 5 deletions src/SeqCli/Cli/Commands/ApiKey/CreateCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,7 +17,7 @@
using System.Threading.Tasks;
using Seq.Api.Model.Inputs;
using Seq.Api.Model.LogEvents;
using Seq.Api.Model.Signals;
using Seq.Api.Model.Shared;
using SeqCli.Cli.Features;
using SeqCli.Config;
using SeqCli.Connection;
Expand DownExpand Up@@ -82,17 +82,17 @@ protected override async Task<int> Run()
var apiKey = await connection.ApiKeys.TemplateAsync();

apiKey.Title = _title;
apiKey.AppliedProperties = _properties.Properties
apiKey.InputSettings.AppliedProperties = _properties.Properties
.Select(kvp => new InputAppliedPropertyPart {Name = kvp.Key, Value = kvp.Value})
.ToList();
apiKey.UseServerTimestamps = _useServerTimestamps;
apiKey.InputSettings.UseServerTimestamps = _useServerTimestamps;

// If _token is null, a value will be returned when the key is created
apiKey.Token = _token;

if (_filter != null)
{
apiKey.InputFilter = new SignalFilterPart
apiKey.InputSettings.Filter = new DescriptiveFilterPart
{
Filter = (await connection.Expressions.ToStrictAsync(_filter)).StrictExpression,
FilterNonStrict = _filter
Expand All@@ -101,7 +101,7 @@ protected override async Task<int> Run()

if (_level != null)
{
apiKey.MinimumLevel = Enum.Parse<LogEventLevel>(LevelMapping.ToFullLevelName(_level));
apiKey.InputSettings.MinimumLevel = Enum.Parse<LogEventLevel>(LevelMapping.ToFullLevelName(_level));
}

apiKey = await connection.ApiKeys.AddAsync(apiKey);
Expand Down
7 changes: 4 additions & 3 deletions src/SeqCli/Cli/Commands/Dashboard/RenderCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,9 +39,9 @@ class RenderCommand : Command
readonly ConnectionFeature _connection;
readonly OutputFormatFeature _output;
readonly SignalExpressionFeature _signal;
readonly TimeoutFeature _timeout;

string _id, _lastDuration, _intervalDuration, _chartTitle;
int? _timeoutMS;

public RenderCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config)
{
Expand All@@ -62,7 +62,7 @@ public RenderCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config
v => _intervalDuration = ArgumentString.Normalize(v));
_range = Enable<DateRangeFeature>();
_signal = Enable<SignalExpressionFeature>();
Options.Add("timeout=", "The query execution timeout in milliseconds", v => _timeoutMS = int.Parse(v?.Trim() ?? "0"));
_timeout = Enable<TimeoutFeature>();
_output = Enable(new OutputFormatFeature(config.Output));
_connection = Enable<ConnectionFeature>();
}
Expand DownExpand Up@@ -158,7 +158,8 @@ protected override async Task<int> Run()

var q = BuildSqlQuery(query, rangeStart, rangeEnd, timeGrouping);

var timeout = _timeoutMS.HasValue ? TimeSpan.FromMilliseconds(_timeoutMS.Value) : (TimeSpan?)null;
var timeout = _timeout.ApplyTimeout(connection.Client.HttpClient);

if (_output.Json)
{
var result = await connection.Data.QueryAsync(q, signal: signal, timeout: timeout);
Expand Down
6 changes: 5 additions & 1 deletion src/SeqCli/Cli/Commands/HelpCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -96,7 +96,11 @@ void PrintMarkdownHelp(string executableName)
{
if (cmd.Count() == 1)
{
Console.WriteLine($" - [`{cmd.Key}`](#{cmd.Key}) &mdash; {cmd.Single().Metadata.HelpText}.");
var single = cmd.Single();
if (single.Metadata.SubCommand == null)
Console.WriteLine($" - [`{cmd.Key}`](#{cmd.Key}) &mdash; {single.Metadata.HelpText}.");
else
Console.WriteLine($" - [`{cmd.Key} {single.Metadata.SubCommand}`](#{cmd.Key}-{single.Metadata.SubCommand}) &mdash; {single.Metadata.HelpText}.");
}
else
{
Expand Down
16 changes: 6 additions & 10 deletions src/SeqCli/Cli/Commands/QueryCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,6 +20,8 @@
using SeqCli.Connection;
using Serilog;

// ReSharper disable UnusedType.Global

namespace SeqCli.Cli.Commands
{
[Command("query", "Execute an SQL query and receive results in CSV format",
Expand All@@ -31,8 +33,8 @@ class QueryCommand : Command
readonly ConnectionFeature _connection;
readonly DateRangeFeature _range;
readonly SignalExpressionFeature _signal;
readonly TimeoutFeature _timeout;
string _query;
int? _timeoutMS;

public QueryCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config)
{
Expand All@@ -41,7 +43,7 @@ public QueryCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config)
Options.Add("q=|query=", "The query to execute", v => _query = v);
_range = Enable<DateRangeFeature>();
_signal = Enable<SignalExpressionFeature>();
Options.Add("timeout=", "The query execution timeout in milliseconds", v => _timeoutMS = int.Parse(v?.Trim() ?? "0"));
_timeout = Enable<TimeoutFeature>();
_output = Enable(new OutputFormatFeature(config.Output));
_connection = Enable<ConnectionFeature>();
}
Expand All@@ -55,15 +57,9 @@ protected override async Task<int> Run()
}

var connection = _connectionFactory.Connect(_connection);

var timeout = _timeoutMS.HasValue ? TimeSpan.FromMilliseconds(_timeoutMS.Value) : (TimeSpan?)null;
if (timeout != null)
{
// The timeout is applied server-side; allowing an extra 10 seconds here means that the
// user experience will be consistent - the error message will be the server's message, etc.
connection.Client.HttpClient.Timeout = timeout.Value.Add(TimeSpan.FromSeconds(10));
}

var timeout = _timeout.ApplyTimeout(connection.Client.HttpClient);

if (_output.Json)
{
var result = await connection.Data.QueryAsync(_query, _range.Start, _range.End, _signal.Signal, timeout: timeout);
Expand Down
3 changes: 2 additions & 1 deletion src/SeqCli/Cli/Commands/Signal/CreateCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,7 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Seq.Api.Model.Shared;
using Seq.Api.Model.Signals;
using SeqCli.Cli.Features;
using SeqCli.Config;
Expand DownExpand Up@@ -101,7 +102,7 @@ protected override async Task<int> Run()
{
signal.Filters = new[]
{
new SignalFilterPart
new DescriptiveFilterPart
{
Filter = (await connection.Expressions.ToStrictAsync(_filter)).StrictExpression,
FilterNonStrict = _filter
Expand Down
2 changes: 1 addition & 1 deletion src/SeqCli/Cli/Commands/Signal/ImportCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -69,7 +69,7 @@ protected override async Task<int> Run()
dest.Grouping = src.Grouping;
dest.IsProtected = src.IsProtected;
dest.Filters = src.Filters;
dest.TaggedProperties = src.TaggedProperties;
dest.Columns = src.Columns;
dest.OwnerId = _entityOwner.OwnerId;
await connection.Signals.AddAsync(dest);
}
Expand Down
3 changes: 2 additions & 1 deletion src/SeqCli/Cli/Commands/User/CreateCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,7 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Seq.Api.Model.Shared;
using Seq.Api.Model.Signals;
using SeqCli.Cli.Features;
using SeqCli.Config;
Expand DownExpand Up@@ -128,7 +129,7 @@ protected override async Task<int> Run()

if (_filter != null)
{
user.ViewFilter = new SignalFilterPart
user.ViewFilter = new DescriptiveFilterPart
{
Filter = (await connection.Expressions.ToStrictAsync(_filter)).StrictExpression,
FilterNonStrict = _filter
Expand Down
46 changes: 46 additions & 0 deletions src/SeqCli/Cli/Features/TimeoutFeature.cs
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
// Copyright Datalust Pty Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Net.Http;

namespace SeqCli.Cli.Features
{
class TimeoutFeature: CommandFeature
{
int? _timeoutMS;

public override void Enable(OptionSet options)
{
options.Add("timeout=", "The execution timeout in milliseconds", v => _timeoutMS = int.Parse(v?.Trim() ?? "0"));
}

// Ensures we don't forget to configure the client whenever the server is given a longer timeout than
// the client's internal default.
public TimeSpan? ApplyTimeout(HttpClient httpClient)
{
if (httpClient == null) throw new ArgumentNullException(nameof(httpClient));

var timeout = _timeoutMS.HasValue ? TimeSpan.FromMilliseconds(_timeoutMS.Value) : (TimeSpan?)null;
if (timeout != null)
{
// The timeout is applied server-side; allowing an extra 10 seconds here means that the
// user experience will be consistent - the error message will be the server's message, etc.
httpClient.Timeout = timeout.Value.Add(TimeSpan.FromSeconds(10));
}

return timeout;
}
}
}
6 changes: 3 additions & 3 deletions src/SeqCli/SeqCli.csproj
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp2.2</TargetFrameworks>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AssemblyName>seqcli</AssemblyName>
<ApplicationIcon>..\..\asset\SeqCli.ico</ApplicationIcon>
<RuntimeIdentifiers>win-x64;linux-x64;osx-x64</RuntimeIdentifiers>
<GenerateAssemblyInformationalVersionAttribute>True</GenerateAssemblyInformationalVersionAttribute>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<TreatSpecificWarningsAsErrors />
<Platforms>x64</Platforms>
<LangVersion>7.3</LangVersion>
<LangVersion>8</LangVersion>
</PropertyGroup>
<Import Project="..\..\SeqCli.Runtime.targets" />
<ItemGroup>
Expand All@@ -30,7 +30,7 @@
<PackageReference Include="Superpower" Version="2.3.0" />
<PackageReference Include="System.Reactive" Version="4.3.1" />
<PackageReference Include="System.Security.Cryptography.ProtectedData" Version="4.7.0" />
<PackageReference Include="Seq.Api" Version="5.1.2-*" />
<PackageReference Include="Seq.Api" Version="2020.1.0" />
<PackageReference Include="Seq.Apps" Version="5.1.0" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions test/SeqCli.EndToEnd/SeqCli.EndToEnd.csproj
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,9 +2,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp2.2</TargetFrameworks>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Platforms>x64</Platforms>
<LangVersion>7.3</LangVersion>
<LangVersion>8</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Autofac" Version="4.9.4" />
Expand Down
7 changes: 2 additions & 5 deletions test/SeqCli.Tests/Cli/NoDuplicateCommands.cs
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq;
using System.Reflection;
using System.Text;
using SeqCli.Cli;
using Xunit;

Expand All@@ -20,7 +17,7 @@ public void EnsureNoDuplicateCommands()
.GroupBy(t => new {t.Attribute.Name, t.Attribute.SubCommand})
.Any(t => t.Count() > 1);

Assert.Equal(anyDuplicates, false);
Assert.False(anyDuplicates);
}
}
}
1 change: 0 additions & 1 deletion test/SeqCli.Tests/PlainText/FrameReaderTests.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,6 @@
using System.IO;
using System.Text;
using System.Threading.Tasks;
using SeqCli.PlainText;
using SeqCli.PlainText.Framing;
using SeqCli.PlainText.Parsers;
using Superpower;
Expand Down
3 changes: 2 additions & 1 deletion test/SeqCli.Tests/SeqCli.Tests.csproj
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Platforms>x64</Platforms>
<LangVersion>8</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
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
2 changes: 1 addition & 1 deletion Build.Docker.ps1
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,7 @@ $IsCIBuild = $null -ne $env:APPVEYOR_BUILD_NUMBER
$IsPublishedBuild = ($env:APPVEYOR_REPO_BRANCH -eq "master" -or $env:APPVEYOR_REPO_BRANCH -eq "dev") -and $null -eq $env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH

$version = @{ $true = $env:APPVEYOR_BUILD_VERSION; $false = "99.99.99" }[$env:APPVEYOR_BUILD_VERSION -ne $NULL];
$framework = "netcoreapp2.2"
$framework = "netcoreapp3.1"
$rid = "linux-x64"
$tag = "datalust/seqcli-ci:$version"

Expand Down
2 changes: 1 addition & 1 deletion Build.ps1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
$ErrorActionPreference = 'Stop'

$framework = 'netcoreapp2.2'
$framework = 'netcoreapp3.1'

function Clean-Output
{
Expand Down
195 changes: 141 additions & 54 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion appveyor.yml
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
version: 5.1.{build}
version: 2020.1.{build}
skip_tags: true
image:
- Visual Studio 2019
Expand Down
2 changes: 1 addition & 1 deletion dockerfiles/seqcli/Dockerfile
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,7 +17,7 @@ RUN apt-get update \
&& rm -rf /var/lib/apt/lists/*

COPY dockerfiles/seqcli/run.sh /run.sh
COPY src/SeqCli/bin/Release/netcoreapp2.2/linux-x64/publish /bin/seqcli
COPY src/SeqCli/bin/Release/netcoreapp3.1/linux-x64/publish /bin/seqcli

ENTRYPOINT ["/run.sh"]

Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "2.2.105"
"version": "3.1.201"
}
}
21 changes: 13 additions & 8 deletions seqcli.sln
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,12 +14,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sln", "sln", "{2EA56595-519
LICENSE = LICENSE
README.md = README.md
SeqCli.Runtime.targets = SeqCli.Runtime.targets
setup.sh = setup.sh
Build.Docker.ps1 = Build.Docker.ps1
docker-publish.ps1 = docker-publish.ps1
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{3587B633-0C03-4235-8903-6226900328F1}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "setup", "setup", "{203E8AE7-ADF0-44FA-A341-90723C8595F7}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "asset", "asset", "{438A0DA5-F3CF-4FCE-B43A-B6DA2981D4AE}"
ProjectSection(SolutionItems) = preProject
asset\SeqCli-Icon-128px.ico = asset\SeqCli-Icon-128px.ico
Expand All@@ -32,10 +33,17 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SeqCli", "src\SeqCli\SeqCli
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SeqCli.Tests", "test\SeqCli.Tests\SeqCli.Tests.csproj", "{DBC69360-519B-4A9B-829B-2AE1B5412521}"
EndProject
Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "SeqCli.Setup", "setup\SeqCli.Setup\SeqCli.Setup.wixproj", "{5E28D963-3523-49DE-B03B-E76684258415}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SeqCli.EndToEnd", "test\SeqCli.EndToEnd\SeqCli.EndToEnd.csproj", "{B86DEF3C-C461-4126-AD49-986EBB19B487}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dockerfiles", "dockerfiles", "{0779824B-502D-450B-BB43-036949C911C4}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "seqcli", "seqcli", "{7F7CAC3A-1046-4D2B-BF9F-F14525918295}"
ProjectSection(SolutionItems) = preProject
dockerfiles\seqcli\.gitignore = dockerfiles\seqcli\.gitignore
dockerfiles\seqcli\Dockerfile = dockerfiles\seqcli\Dockerfile
dockerfiles\seqcli\run.sh = dockerfiles\seqcli\run.sh
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Expand All@@ -50,9 +58,6 @@ Global
{DBC69360-519B-4A9B-829B-2AE1B5412521}.Debug|x64.Build.0 = Debug|x64
{DBC69360-519B-4A9B-829B-2AE1B5412521}.Release|x64.ActiveCfg = Release|x64
{DBC69360-519B-4A9B-829B-2AE1B5412521}.Release|x64.Build.0 = Release|x64
{5E28D963-3523-49DE-B03B-E76684258415}.Debug|x64.ActiveCfg = Debug|x64
{5E28D963-3523-49DE-B03B-E76684258415}.Release|x64.ActiveCfg = Release|x64
{5E28D963-3523-49DE-B03B-E76684258415}.Release|x64.Build.0 = Release|x64
{B86DEF3C-C461-4126-AD49-986EBB19B487}.Debug|x64.ActiveCfg = Debug|x64
{B86DEF3C-C461-4126-AD49-986EBB19B487}.Debug|x64.Build.0 = Debug|x64
{B86DEF3C-C461-4126-AD49-986EBB19B487}.Release|x64.ActiveCfg = Release|x64
Expand All@@ -64,8 +69,8 @@ Global
GlobalSection(NestedProjects) = preSolution
{EBDBEED2-A1BC-4269-B6B0-EA908CE4D687} = {FC0A256C-CC1F-4ECE-AF09-707248D10DC1}
{DBC69360-519B-4A9B-829B-2AE1B5412521} = {3587B633-0C03-4235-8903-6226900328F1}
{5E28D963-3523-49DE-B03B-E76684258415} = {203E8AE7-ADF0-44FA-A341-90723C8595F7}
{B86DEF3C-C461-4126-AD49-986EBB19B487} = {3587B633-0C03-4235-8903-6226900328F1}
{7F7CAC3A-1046-4D2B-BF9F-F14525918295} = {0779824B-502D-450B-BB43-036949C911C4}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6D299713-28D4-4078-9DA7-9033679CD200}
Expand Down
10 changes: 5 additions & 5 deletions src/SeqCli/Cli/Commands/ApiKey/CreateCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,7 +17,7 @@
using System.Threading.Tasks;
using Seq.Api.Model.Inputs;
using Seq.Api.Model.LogEvents;
using Seq.Api.Model.Signals;
using Seq.Api.Model.Shared;
using SeqCli.Cli.Features;
using SeqCli.Config;
using SeqCli.Connection;
Expand DownExpand Up@@ -82,17 +82,17 @@ protected override async Task<int> Run()
var apiKey = await connection.ApiKeys.TemplateAsync();

apiKey.Title = _title;
apiKey.AppliedProperties = _properties.Properties
apiKey.InputSettings.AppliedProperties = _properties.Properties
.Select(kvp => new InputAppliedPropertyPart {Name = kvp.Key, Value = kvp.Value})
.ToList();
apiKey.UseServerTimestamps = _useServerTimestamps;
apiKey.InputSettings.UseServerTimestamps = _useServerTimestamps;

// If _token is null, a value will be returned when the key is created
apiKey.Token = _token;

if (_filter != null)
{
apiKey.InputFilter = new SignalFilterPart
apiKey.InputSettings.Filter = new DescriptiveFilterPart
{
Filter = (await connection.Expressions.ToStrictAsync(_filter)).StrictExpression,
FilterNonStrict = _filter
Expand All@@ -101,7 +101,7 @@ protected override async Task<int> Run()

if (_level != null)
{
apiKey.MinimumLevel = Enum.Parse<LogEventLevel>(LevelMapping.ToFullLevelName(_level));
apiKey.InputSettings.MinimumLevel = Enum.Parse<LogEventLevel>(LevelMapping.ToFullLevelName(_level));
}

apiKey = await connection.ApiKeys.AddAsync(apiKey);
Expand Down
7 changes: 4 additions & 3 deletions src/SeqCli/Cli/Commands/Dashboard/RenderCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,9 +39,9 @@ class RenderCommand : Command
readonly ConnectionFeature _connection;
readonly OutputFormatFeature _output;
readonly SignalExpressionFeature _signal;
readonly TimeoutFeature _timeout;

string _id, _lastDuration, _intervalDuration, _chartTitle;
int? _timeoutMS;

public RenderCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config)
{
Expand All@@ -62,7 +62,7 @@ public RenderCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config
v => _intervalDuration = ArgumentString.Normalize(v));
_range = Enable<DateRangeFeature>();
_signal = Enable<SignalExpressionFeature>();
Options.Add("timeout=", "The query execution timeout in milliseconds", v => _timeoutMS = int.Parse(v?.Trim() ?? "0"));
_timeout = Enable<TimeoutFeature>();
_output = Enable(new OutputFormatFeature(config.Output));
_connection = Enable<ConnectionFeature>();
}
Expand DownExpand Up@@ -158,7 +158,8 @@ protected override async Task<int> Run()

var q = BuildSqlQuery(query, rangeStart, rangeEnd, timeGrouping);

var timeout = _timeoutMS.HasValue ? TimeSpan.FromMilliseconds(_timeoutMS.Value) : (TimeSpan?)null;
var timeout = _timeout.ApplyTimeout(connection.Client.HttpClient);

if (_output.Json)
{
var result = await connection.Data.QueryAsync(q, signal: signal, timeout: timeout);
Expand Down
6 changes: 5 additions & 1 deletion src/SeqCli/Cli/Commands/HelpCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -96,7 +96,11 @@ void PrintMarkdownHelp(string executableName)
{
if (cmd.Count() == 1)
{
Console.WriteLine($" - [`{cmd.Key}`](#{cmd.Key}) &mdash; {cmd.Single().Metadata.HelpText}.");
var single = cmd.Single();
if (single.Metadata.SubCommand == null)
Console.WriteLine($" - [`{cmd.Key}`](#{cmd.Key}) &mdash; {single.Metadata.HelpText}.");
else
Console.WriteLine($" - [`{cmd.Key} {single.Metadata.SubCommand}`](#{cmd.Key}-{single.Metadata.SubCommand}) &mdash; {single.Metadata.HelpText}.");
}
else
{
Expand Down
16 changes: 6 additions & 10 deletions src/SeqCli/Cli/Commands/QueryCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,6 +20,8 @@
using SeqCli.Connection;
using Serilog;

// ReSharper disable UnusedType.Global

namespace SeqCli.Cli.Commands
{
[Command("query", "Execute an SQL query and receive results in CSV format",
Expand All@@ -31,8 +33,8 @@ class QueryCommand : Command
readonly ConnectionFeature _connection;
readonly DateRangeFeature _range;
readonly SignalExpressionFeature _signal;
readonly TimeoutFeature _timeout;
string _query;
int? _timeoutMS;

public QueryCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config)
{
Expand All@@ -41,7 +43,7 @@ public QueryCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config)
Options.Add("q=|query=", "The query to execute", v => _query = v);
_range = Enable<DateRangeFeature>();
_signal = Enable<SignalExpressionFeature>();
Options.Add("timeout=", "The query execution timeout in milliseconds", v => _timeoutMS = int.Parse(v?.Trim() ?? "0"));
_timeout = Enable<TimeoutFeature>();
_output = Enable(new OutputFormatFeature(config.Output));
_connection = Enable<ConnectionFeature>();
}
Expand All@@ -55,15 +57,9 @@ protected override async Task<int> Run()
}

var connection = _connectionFactory.Connect(_connection);

var timeout = _timeoutMS.HasValue ? TimeSpan.FromMilliseconds(_timeoutMS.Value) : (TimeSpan?)null;
if (timeout != null)
{
// The timeout is applied server-side; allowing an extra 10 seconds here means that the
// user experience will be consistent - the error message will be the server's message, etc.
connection.Client.HttpClient.Timeout = timeout.Value.Add(TimeSpan.FromSeconds(10));
}

var timeout = _timeout.ApplyTimeout(connection.Client.HttpClient);

if (_output.Json)
{
var result = await connection.Data.QueryAsync(_query, _range.Start, _range.End, _signal.Signal, timeout: timeout);
Expand Down
3 changes: 2 additions & 1 deletion src/SeqCli/Cli/Commands/Signal/CreateCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,7 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Seq.Api.Model.Shared;
using Seq.Api.Model.Signals;
using SeqCli.Cli.Features;
using SeqCli.Config;
Expand DownExpand Up@@ -101,7 +102,7 @@ protected override async Task<int> Run()
{
signal.Filters = new[]
{
new SignalFilterPart
new DescriptiveFilterPart
{
Filter = (await connection.Expressions.ToStrictAsync(_filter)).StrictExpression,
FilterNonStrict = _filter
Expand Down
2 changes: 1 addition & 1 deletion src/SeqCli/Cli/Commands/Signal/ImportCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -69,7 +69,7 @@ protected override async Task<int> Run()
dest.Grouping = src.Grouping;
dest.IsProtected = src.IsProtected;
dest.Filters = src.Filters;
dest.TaggedProperties = src.TaggedProperties;
dest.Columns = src.Columns;
dest.OwnerId = _entityOwner.OwnerId;
await connection.Signals.AddAsync(dest);
}
Expand Down
3 changes: 2 additions & 1 deletion src/SeqCli/Cli/Commands/User/CreateCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,7 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Seq.Api.Model.Shared;
using Seq.Api.Model.Signals;
using SeqCli.Cli.Features;
using SeqCli.Config;
Expand DownExpand Up@@ -128,7 +129,7 @@ protected override async Task<int> Run()

if (_filter != null)
{
user.ViewFilter = new SignalFilterPart
user.ViewFilter = new DescriptiveFilterPart
{
Filter = (await connection.Expressions.ToStrictAsync(_filter)).StrictExpression,
FilterNonStrict = _filter
Expand Down
46 changes: 46 additions & 0 deletions src/SeqCli/Cli/Features/TimeoutFeature.cs
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
// Copyright Datalust Pty Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Net.Http;

namespace SeqCli.Cli.Features
{
class TimeoutFeature: CommandFeature
{
int? _timeoutMS;

public override void Enable(OptionSet options)
{
options.Add("timeout=", "The execution timeout in milliseconds", v => _timeoutMS = int.Parse(v?.Trim() ?? "0"));
}

// Ensures we don't forget to configure the client whenever the server is given a longer timeout than
// the client's internal default.
public TimeSpan? ApplyTimeout(HttpClient httpClient)
{
if (httpClient == null) throw new ArgumentNullException(nameof(httpClient));

var timeout = _timeoutMS.HasValue ? TimeSpan.FromMilliseconds(_timeoutMS.Value) : (TimeSpan?)null;
if (timeout != null)
{
// The timeout is applied server-side; allowing an extra 10 seconds here means that the
// user experience will be consistent - the error message will be the server's message, etc.
httpClient.Timeout = timeout.Value.Add(TimeSpan.FromSeconds(10));
}

return timeout;
}
}
}
6 changes: 3 additions & 3 deletions src/SeqCli/SeqCli.csproj
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp2.2</TargetFrameworks>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AssemblyName>seqcli</AssemblyName>
<ApplicationIcon>..\..\asset\SeqCli.ico</ApplicationIcon>
<RuntimeIdentifiers>win-x64;linux-x64;osx-x64</RuntimeIdentifiers>
<GenerateAssemblyInformationalVersionAttribute>True</GenerateAssemblyInformationalVersionAttribute>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<TreatSpecificWarningsAsErrors />
<Platforms>x64</Platforms>
<LangVersion>7.3</LangVersion>
<LangVersion>8</LangVersion>
</PropertyGroup>
<Import Project="..\..\SeqCli.Runtime.targets" />
<ItemGroup>
Expand All@@ -30,7 +30,7 @@
<PackageReference Include="Superpower" Version="2.3.0" />
<PackageReference Include="System.Reactive" Version="4.3.1" />
<PackageReference Include="System.Security.Cryptography.ProtectedData" Version="4.7.0" />
<PackageReference Include="Seq.Api" Version="5.1.2-*" />
<PackageReference Include="Seq.Api" Version="2020.1.0" />
<PackageReference Include="Seq.Apps" Version="5.1.0" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions test/SeqCli.EndToEnd/SeqCli.EndToEnd.csproj
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,9 +2,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp2.2</TargetFrameworks>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Platforms>x64</Platforms>
<LangVersion>7.3</LangVersion>
<LangVersion>8</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Autofac" Version="4.9.4" />
Expand Down
7 changes: 2 additions & 5 deletions test/SeqCli.Tests/Cli/NoDuplicateCommands.cs
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq;
using System.Reflection;
using System.Text;
using SeqCli.Cli;
using Xunit;

Expand All@@ -20,7 +17,7 @@ public void EnsureNoDuplicateCommands()
.GroupBy(t => new {t.Attribute.Name, t.Attribute.SubCommand})
.Any(t => t.Count() > 1);

Assert.Equal(anyDuplicates, false);
Assert.False(anyDuplicates);
}
}
}
1 change: 0 additions & 1 deletion test/SeqCli.Tests/PlainText/FrameReaderTests.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,6 @@
using System.IO;
using System.Text;
using System.Threading.Tasks;
using SeqCli.PlainText;
using SeqCli.PlainText.Framing;
using SeqCli.PlainText.Parsers;
using Superpower;
Expand Down
3 changes: 2 additions & 1 deletion test/SeqCli.Tests/SeqCli.Tests.csproj
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Platforms>x64</Platforms>
<LangVersion>8</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content
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
2 changes: 1 addition & 1 deletion Build.Docker.ps1
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,7 @@ $IsCIBuild = $null -ne $env:APPVEYOR_BUILD_NUMBER
$IsPublishedBuild = ($env:APPVEYOR_REPO_BRANCH -eq "master" -or $env:APPVEYOR_REPO_BRANCH -eq "dev") -and $null -eq $env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH

$version = @{ $true = $env:APPVEYOR_BUILD_VERSION; $false = "99.99.99" }[$env:APPVEYOR_BUILD_VERSION -ne $NULL];
$framework = "netcoreapp2.2"
$framework = "netcoreapp3.1"
$rid = "linux-x64"
$tag = "datalust/seqcli-ci:$version"

Expand Down
2 changes: 1 addition & 1 deletion Build.ps1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
$ErrorActionPreference = 'Stop'

$framework = 'netcoreapp2.2'
$framework = 'netcoreapp3.1'

function Clean-Output
{
Expand Down
195 changes: 141 additions & 54 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion appveyor.yml
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
version: 5.1.{build}
version: 2020.1.{build}
skip_tags: true
image:
- Visual Studio 2019
Expand Down
2 changes: 1 addition & 1 deletion dockerfiles/seqcli/Dockerfile
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,7 +17,7 @@ RUN apt-get update \
&& rm -rf /var/lib/apt/lists/*

COPY dockerfiles/seqcli/run.sh /run.sh
COPY src/SeqCli/bin/Release/netcoreapp2.2/linux-x64/publish /bin/seqcli
COPY src/SeqCli/bin/Release/netcoreapp3.1/linux-x64/publish /bin/seqcli

ENTRYPOINT ["/run.sh"]

Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "2.2.105"
"version": "3.1.201"
}
}
21 changes: 13 additions & 8 deletions seqcli.sln
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,12 +14,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sln", "sln", "{2EA56595-519
LICENSE = LICENSE
README.md = README.md
SeqCli.Runtime.targets = SeqCli.Runtime.targets
setup.sh = setup.sh
Build.Docker.ps1 = Build.Docker.ps1
docker-publish.ps1 = docker-publish.ps1
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{3587B633-0C03-4235-8903-6226900328F1}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "setup", "setup", "{203E8AE7-ADF0-44FA-A341-90723C8595F7}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "asset", "asset", "{438A0DA5-F3CF-4FCE-B43A-B6DA2981D4AE}"
ProjectSection(SolutionItems) = preProject
asset\SeqCli-Icon-128px.ico = asset\SeqCli-Icon-128px.ico
Expand All@@ -32,10 +33,17 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SeqCli", "src\SeqCli\SeqCli
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SeqCli.Tests", "test\SeqCli.Tests\SeqCli.Tests.csproj", "{DBC69360-519B-4A9B-829B-2AE1B5412521}"
EndProject
Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "SeqCli.Setup", "setup\SeqCli.Setup\SeqCli.Setup.wixproj", "{5E28D963-3523-49DE-B03B-E76684258415}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SeqCli.EndToEnd", "test\SeqCli.EndToEnd\SeqCli.EndToEnd.csproj", "{B86DEF3C-C461-4126-AD49-986EBB19B487}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dockerfiles", "dockerfiles", "{0779824B-502D-450B-BB43-036949C911C4}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "seqcli", "seqcli", "{7F7CAC3A-1046-4D2B-BF9F-F14525918295}"
ProjectSection(SolutionItems) = preProject
dockerfiles\seqcli\.gitignore = dockerfiles\seqcli\.gitignore
dockerfiles\seqcli\Dockerfile = dockerfiles\seqcli\Dockerfile
dockerfiles\seqcli\run.sh = dockerfiles\seqcli\run.sh
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Expand All@@ -50,9 +58,6 @@ Global
{DBC69360-519B-4A9B-829B-2AE1B5412521}.Debug|x64.Build.0 = Debug|x64
{DBC69360-519B-4A9B-829B-2AE1B5412521}.Release|x64.ActiveCfg = Release|x64
{DBC69360-519B-4A9B-829B-2AE1B5412521}.Release|x64.Build.0 = Release|x64
{5E28D963-3523-49DE-B03B-E76684258415}.Debug|x64.ActiveCfg = Debug|x64
{5E28D963-3523-49DE-B03B-E76684258415}.Release|x64.ActiveCfg = Release|x64
{5E28D963-3523-49DE-B03B-E76684258415}.Release|x64.Build.0 = Release|x64
{B86DEF3C-C461-4126-AD49-986EBB19B487}.Debug|x64.ActiveCfg = Debug|x64
{B86DEF3C-C461-4126-AD49-986EBB19B487}.Debug|x64.Build.0 = Debug|x64
{B86DEF3C-C461-4126-AD49-986EBB19B487}.Release|x64.ActiveCfg = Release|x64
Expand All@@ -64,8 +69,8 @@ Global
GlobalSection(NestedProjects) = preSolution
{EBDBEED2-A1BC-4269-B6B0-EA908CE4D687} = {FC0A256C-CC1F-4ECE-AF09-707248D10DC1}
{DBC69360-519B-4A9B-829B-2AE1B5412521} = {3587B633-0C03-4235-8903-6226900328F1}
{5E28D963-3523-49DE-B03B-E76684258415} = {203E8AE7-ADF0-44FA-A341-90723C8595F7}
{B86DEF3C-C461-4126-AD49-986EBB19B487} = {3587B633-0C03-4235-8903-6226900328F1}
{7F7CAC3A-1046-4D2B-BF9F-F14525918295} = {0779824B-502D-450B-BB43-036949C911C4}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6D299713-28D4-4078-9DA7-9033679CD200}
Expand Down
10 changes: 5 additions & 5 deletions src/SeqCli/Cli/Commands/ApiKey/CreateCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,7 +17,7 @@
using System.Threading.Tasks;
using Seq.Api.Model.Inputs;
using Seq.Api.Model.LogEvents;
using Seq.Api.Model.Signals;
using Seq.Api.Model.Shared;
using SeqCli.Cli.Features;
using SeqCli.Config;
using SeqCli.Connection;
Expand DownExpand Up@@ -82,17 +82,17 @@ protected override async Task<int> Run()
var apiKey = await connection.ApiKeys.TemplateAsync();

apiKey.Title = _title;
apiKey.AppliedProperties = _properties.Properties
apiKey.InputSettings.AppliedProperties = _properties.Properties
.Select(kvp => new InputAppliedPropertyPart {Name = kvp.Key, Value = kvp.Value})
.ToList();
apiKey.UseServerTimestamps = _useServerTimestamps;
apiKey.InputSettings.UseServerTimestamps = _useServerTimestamps;

// If _token is null, a value will be returned when the key is created
apiKey.Token = _token;

if (_filter != null)
{
apiKey.InputFilter = new SignalFilterPart
apiKey.InputSettings.Filter = new DescriptiveFilterPart
{
Filter = (await connection.Expressions.ToStrictAsync(_filter)).StrictExpression,
FilterNonStrict = _filter
Expand All@@ -101,7 +101,7 @@ protected override async Task<int> Run()

if (_level != null)
{
apiKey.MinimumLevel = Enum.Parse<LogEventLevel>(LevelMapping.ToFullLevelName(_level));
apiKey.InputSettings.MinimumLevel = Enum.Parse<LogEventLevel>(LevelMapping.ToFullLevelName(_level));
}

apiKey = await connection.ApiKeys.AddAsync(apiKey);
Expand Down
7 changes: 4 additions & 3 deletions src/SeqCli/Cli/Commands/Dashboard/RenderCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,9 +39,9 @@ class RenderCommand : Command
readonly ConnectionFeature _connection;
readonly OutputFormatFeature _output;
readonly SignalExpressionFeature _signal;
readonly TimeoutFeature _timeout;

string _id, _lastDuration, _intervalDuration, _chartTitle;
int? _timeoutMS;

public RenderCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config)
{
Expand All@@ -62,7 +62,7 @@ public RenderCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config
v => _intervalDuration = ArgumentString.Normalize(v));
_range = Enable<DateRangeFeature>();
_signal = Enable<SignalExpressionFeature>();
Options.Add("timeout=", "The query execution timeout in milliseconds", v => _timeoutMS = int.Parse(v?.Trim() ?? "0"));
_timeout = Enable<TimeoutFeature>();
_output = Enable(new OutputFormatFeature(config.Output));
_connection = Enable<ConnectionFeature>();
}
Expand DownExpand Up@@ -158,7 +158,8 @@ protected override async Task<int> Run()

var q = BuildSqlQuery(query, rangeStart, rangeEnd, timeGrouping);

var timeout = _timeoutMS.HasValue ? TimeSpan.FromMilliseconds(_timeoutMS.Value) : (TimeSpan?)null;
var timeout = _timeout.ApplyTimeout(connection.Client.HttpClient);

if (_output.Json)
{
var result = await connection.Data.QueryAsync(q, signal: signal, timeout: timeout);
Expand Down
6 changes: 5 additions & 1 deletion src/SeqCli/Cli/Commands/HelpCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -96,7 +96,11 @@ void PrintMarkdownHelp(string executableName)
{
if (cmd.Count() == 1)
{
Console.WriteLine($" - [`{cmd.Key}`](#{cmd.Key}) &mdash; {cmd.Single().Metadata.HelpText}.");
var single = cmd.Single();
if (single.Metadata.SubCommand == null)
Console.WriteLine($" - [`{cmd.Key}`](#{cmd.Key}) &mdash; {single.Metadata.HelpText}.");
else
Console.WriteLine($" - [`{cmd.Key} {single.Metadata.SubCommand}`](#{cmd.Key}-{single.Metadata.SubCommand}) &mdash; {single.Metadata.HelpText}.");
}
else
{
Expand Down
16 changes: 6 additions & 10 deletions src/SeqCli/Cli/Commands/QueryCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,6 +20,8 @@
using SeqCli.Connection;
using Serilog;

// ReSharper disable UnusedType.Global

namespace SeqCli.Cli.Commands
{
[Command("query", "Execute an SQL query and receive results in CSV format",
Expand All@@ -31,8 +33,8 @@ class QueryCommand : Command
readonly ConnectionFeature _connection;
readonly DateRangeFeature _range;
readonly SignalExpressionFeature _signal;
readonly TimeoutFeature _timeout;
string _query;
int? _timeoutMS;

public QueryCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config)
{
Expand All@@ -41,7 +43,7 @@ public QueryCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config)
Options.Add("q=|query=", "The query to execute", v => _query = v);
_range = Enable<DateRangeFeature>();
_signal = Enable<SignalExpressionFeature>();
Options.Add("timeout=", "The query execution timeout in milliseconds", v => _timeoutMS = int.Parse(v?.Trim() ?? "0"));
_timeout = Enable<TimeoutFeature>();
_output = Enable(new OutputFormatFeature(config.Output));
_connection = Enable<ConnectionFeature>();
}
Expand All@@ -55,15 +57,9 @@ protected override async Task<int> Run()
}

var connection = _connectionFactory.Connect(_connection);

var timeout = _timeoutMS.HasValue ? TimeSpan.FromMilliseconds(_timeoutMS.Value) : (TimeSpan?)null;
if (timeout != null)
{
// The timeout is applied server-side; allowing an extra 10 seconds here means that the
// user experience will be consistent - the error message will be the server's message, etc.
connection.Client.HttpClient.Timeout = timeout.Value.Add(TimeSpan.FromSeconds(10));
}

var timeout = _timeout.ApplyTimeout(connection.Client.HttpClient);

if (_output.Json)
{
var result = await connection.Data.QueryAsync(_query, _range.Start, _range.End, _signal.Signal, timeout: timeout);
Expand Down
3 changes: 2 additions & 1 deletion src/SeqCli/Cli/Commands/Signal/CreateCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,7 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Seq.Api.Model.Shared;
using Seq.Api.Model.Signals;
using SeqCli.Cli.Features;
using SeqCli.Config;
Expand DownExpand Up@@ -101,7 +102,7 @@ protected override async Task<int> Run()
{
signal.Filters = new[]
{
new SignalFilterPart
new DescriptiveFilterPart
{
Filter = (await connection.Expressions.ToStrictAsync(_filter)).StrictExpression,
FilterNonStrict = _filter
Expand Down
2 changes: 1 addition & 1 deletion src/SeqCli/Cli/Commands/Signal/ImportCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -69,7 +69,7 @@ protected override async Task<int> Run()
dest.Grouping = src.Grouping;
dest.IsProtected = src.IsProtected;
dest.Filters = src.Filters;
dest.TaggedProperties = src.TaggedProperties;
dest.Columns = src.Columns;
dest.OwnerId = _entityOwner.OwnerId;
await connection.Signals.AddAsync(dest);
}
Expand Down
3 changes: 2 additions & 1 deletion src/SeqCli/Cli/Commands/User/CreateCommand.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,7 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Seq.Api.Model.Shared;
using Seq.Api.Model.Signals;
using SeqCli.Cli.Features;
using SeqCli.Config;
Expand DownExpand Up@@ -128,7 +129,7 @@ protected override async Task<int> Run()

if (_filter != null)
{
user.ViewFilter = new SignalFilterPart
user.ViewFilter = new DescriptiveFilterPart
{
Filter = (await connection.Expressions.ToStrictAsync(_filter)).StrictExpression,
FilterNonStrict = _filter
Expand Down
46 changes: 46 additions & 0 deletions src/SeqCli/Cli/Features/TimeoutFeature.cs
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
// Copyright Datalust Pty Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Net.Http;

namespace SeqCli.Cli.Features
{
class TimeoutFeature: CommandFeature
{
int? _timeoutMS;

public override void Enable(OptionSet options)
{
options.Add("timeout=", "The execution timeout in milliseconds", v => _timeoutMS = int.Parse(v?.Trim() ?? "0"));
}

// Ensures we don't forget to configure the client whenever the server is given a longer timeout than
// the client's internal default.
public TimeSpan? ApplyTimeout(HttpClient httpClient)
{
if (httpClient == null) throw new ArgumentNullException(nameof(httpClient));

var timeout = _timeoutMS.HasValue ? TimeSpan.FromMilliseconds(_timeoutMS.Value) : (TimeSpan?)null;
if (timeout != null)
{
// The timeout is applied server-side; allowing an extra 10 seconds here means that the
// user experience will be consistent - the error message will be the server's message, etc.
httpClient.Timeout = timeout.Value.Add(TimeSpan.FromSeconds(10));
}

return timeout;
}
}
}
6 changes: 3 additions & 3 deletions src/SeqCli/SeqCli.csproj
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp2.2</TargetFrameworks>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AssemblyName>seqcli</AssemblyName>
<ApplicationIcon>..\..\asset\SeqCli.ico</ApplicationIcon>
<RuntimeIdentifiers>win-x64;linux-x64;osx-x64</RuntimeIdentifiers>
<GenerateAssemblyInformationalVersionAttribute>True</GenerateAssemblyInformationalVersionAttribute>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<TreatSpecificWarningsAsErrors />
<Platforms>x64</Platforms>
<LangVersion>7.3</LangVersion>
<LangVersion>8</LangVersion>
</PropertyGroup>
<Import Project="..\..\SeqCli.Runtime.targets" />
<ItemGroup>
Expand All@@ -30,7 +30,7 @@
<PackageReference Include="Superpower" Version="2.3.0" />
<PackageReference Include="System.Reactive" Version="4.3.1" />
<PackageReference Include="System.Security.Cryptography.ProtectedData" Version="4.7.0" />
<PackageReference Include="Seq.Api" Version="5.1.2-*" />
<PackageReference Include="Seq.Api" Version="2020.1.0" />
<PackageReference Include="Seq.Apps" Version="5.1.0" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions test/SeqCli.EndToEnd/SeqCli.EndToEnd.csproj
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,9 +2,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp2.2</TargetFrameworks>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Platforms>x64</Platforms>
<LangVersion>7.3</LangVersion>
<LangVersion>8</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Autofac" Version="4.9.4" />
Expand Down
7 changes: 2 additions & 5 deletions test/SeqCli.Tests/Cli/NoDuplicateCommands.cs
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq;
using System.Reflection;
using System.Text;
using SeqCli.Cli;
using Xunit;

Expand All@@ -20,7 +17,7 @@ public void EnsureNoDuplicateCommands()
.GroupBy(t => new {t.Attribute.Name, t.Attribute.SubCommand})
.Any(t => t.Count() > 1);

Assert.Equal(anyDuplicates, false);
Assert.False(anyDuplicates);
}
}
}
1 change: 0 additions & 1 deletion test/SeqCli.Tests/PlainText/FrameReaderTests.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,6 @@
using System.IO;
using System.Text;
using System.Threading.Tasks;
using SeqCli.PlainText;
using SeqCli.PlainText.Framing;
using SeqCli.PlainText.Parsers;
using Superpower;
Expand Down
3 changes: 2 additions & 1 deletion test/SeqCli.Tests/SeqCli.Tests.csproj
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Platforms>x64</Platforms>
<LangVersion>8</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
Expand Down