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
4 changes: 2 additions & 2 deletions .build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class Build : NukeBuild
utf8JsonWriter.WriteString("name", EncodeName(property.Name));
utf8JsonWriter.WriteString("type", "string");
utf8JsonWriter.WriteString("format", $"--{property.Name} {{value}}");
utf8JsonWriter.WriteString("help", property.Description?.Replace("\n", " "));
utf8JsonWriter.WriteString("help", property.Description?.ReplaceLineEndings(" "));
utf8JsonWriter.WriteEndObject();
}

Expand All @@ -70,7 +70,7 @@ public class Build : NukeBuild
utf8JsonWriter.WriteString("name", EncodeName(property.Name));
utf8JsonWriter.WriteString("type", "string");
utf8JsonWriter.WriteString("format", "{value}");
utf8JsonWriter.WriteString("help", property.Description?.Replace("\n", " "));
utf8JsonWriter.WriteString("help", property.Description?.ReplaceLineEndings(" "));
utf8JsonWriter.WriteEndObject();
}

Expand Down
2 changes: 1 addition & 1 deletion .build/_build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<RootNamespace></RootNamespace>
<NoWarn>CS0649;CS0169</NoWarn>
<NukeRootDirectory>..</NukeRootDirectory>
Expand Down
36 changes: 28 additions & 8 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,43 @@ on:
branches: [ "main" ]

jobs:
ci-build:
runs-on: ubuntu-latest
build-and-test:
name: Build & Test ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
defaults:
run:
working-directory: ./src/Confix.Tool
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v6
- name: Setup .NET
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
8.0.x
9.0.x
10.0.x
dotnet-version: 10.0.401
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build
- name: Test
run: dotnet test
- name: Upload snapshot mismatches
if: failure()
uses: actions/upload-artifact@v4
with:
name: snapshot-mismatches-${{ matrix.os }}
path: src/Confix.Tool/**/__mismatch__/**
if-no-files-found: ignore

ci-build:
name: ci-build
if: ${{ always() }}
needs: build-and-test
runs-on: ubuntu-latest
steps:
- name: Verify build and test results
env:
BUILD_RESULT: ${{ needs.build-and-test.result }}
run: test "$BUILD_RESULT" = "success"
5 changes: 1 addition & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
8.0.x
9.0.x
10.0.x
dotnet-version: 10.0.401
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand Down
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
<Import Condition="Exists($(PropsAbove))" Project="$(PropsAbove)"/>

<PropertyGroup>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<TargetFramework>net10.0</TargetFramework>
<RootNamespace>Confix</RootNamespace>
<Nullable>enable</Nullable>
<LangVersion>11</LangVersion>
<LangVersion>14.0</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

Expand Down
61 changes: 27 additions & 34 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,24 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Azure.Identity" Version="1.13.1" />
<PackageVersion Include="Azure.Security.KeyVault.Secrets" Version="4.7.0" />
<PackageVersion Include="Azure.Security.KeyVault.Keys" Version="4.7.0" />
<PackageVersion Include="HotChocolate" Version="13.1.0" />
<PackageVersion Include="JsonPointer.Net" Version="3.0.3" />
<PackageVersion Include="JsonSchema.Net" Version="4.1.1" />
<PackageVersion Include="Nuke.Build" Version="9.0.4" />
<PackageVersion Include="Nuke.Tooling.Generator" Version="9.0.4" />
<PackageVersion Include="Nuke.Common" Version="9.0.4" />
<PackageVersion Include="Spectre.Console" Version="0.46.0" />
<PackageVersion Include="Spectre.Console.Json" Version="0.46.0" />
<PackageVersion Include="Spectre.Console.Testing" Version="0.47.0" />
<PackageVersion Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageVersion Include="System.Linq.Async" Version="6.0.1" />
<PackageVersion Include="System.Reactive" Version="6.0.0" />
<PackageVersion Include="System.Reflection.MetadataLoadContext" Version="8.0.0" />
<PackageVersion Include="Azure.Identity" Version="1.21.0" />
<PackageVersion Include="Azure.Security.KeyVault.Secrets" Version="4.11.1" />
<PackageVersion Include="Azure.Security.KeyVault.Keys" Version="4.10.1" />
<PackageVersion Include="HotChocolate" Version="16.6.4" />
<PackageVersion Include="JsonPointer.Net" Version="7.0.3" />
<PackageVersion Include="JsonSchema.Net" Version="9.4.0" />
<PackageVersion Include="Nuke.Build" Version="10.1.0" />
<PackageVersion Include="Nuke.Tooling.Generator" Version="10.1.0" />
<PackageVersion Include="Nuke.Common" Version="10.1.0" />
<PackageVersion Include="NuGet.Packaging" Version="6.12.5" />
<PackageVersion Include="Spectre.Console" Version="0.57.2" />
<PackageVersion Include="Spectre.Console.Json" Version="0.57.2" />
<PackageVersion Include="Spectre.Console.Testing" Version="0.57.2" />
<PackageVersion Include="System.CommandLine" Version="2.0.11" />
<PackageVersion Include="System.Linq.Async" Version="7.0.1" />
<PackageVersion Include="System.Reactive" Version="7.0.0" />
<PackageVersion Include="System.Reflection.MetadataLoadContext" Version="10.0.11" />
<PackageVersion Include="System.Security.Cryptography.Xml" Version="10.0.11" />
</ItemGroup>
<ItemGroup>
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
Expand All @@ -39,22 +41,13 @@
<PackageVersion Include="Snapshooter.Xunit" Version="0.13.0" />
<PackageVersion Include="FluentAssertions" Version="6.11.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.FileSystemGlobbing" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Http" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Options" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="9.0.0" />
<ItemGroup Condition="'$(TargetFramework)' == 'net10.0'">
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="10.0.11" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="10.0.11" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="10.0.11" />
<PackageVersion Include="Microsoft.Extensions.FileSystemGlobbing" Version="10.0.11" />
<PackageVersion Include="Microsoft.Extensions.Http" Version="10.0.11" />
<PackageVersion Include="Microsoft.Extensions.Options" Version="10.0.11" />
<PackageVersion Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="10.0.11" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.FileSystemGlobbing" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Http" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.Options" Version="8.0.2" />
<PackageVersion Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
</ItemGroup>
</Project>
</Project>
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "9.0.100",
"version": "10.0.401",
"rollForward": "latestMinor"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ public sealed class ComponentCommand : Command
public ComponentCommand() : base("component")
{
Description = "This command is used to manage components.";
AddCommand(new BuildComponentCommand());
AddCommand(new ComponentInitCommand());
AddCommand(new ComponentListCommand());
AddCommand(new ComponentAddCommand());
Add(new BuildComponentCommand());
Add(new ComponentInitCommand());
Add(new ComponentListCommand());
Add(new ComponentAddCommand());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ public sealed class ConfigCommand : Command
public ConfigCommand() : base("config")
{
Description = "This command is used to manage config.";
AddCommand(new ConfigShowCommand());
AddCommand(new ConfigSetCommand());
AddCommand(new ConfigListCommand());
Add(new ConfigShowCommand());
Add(new ConfigSetCommand());
Add(new ConfigListCommand());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ public ProjectCommand() : base("project")
{
Description = "This command is used to manage projects.";

AddCommand(new ProjectRestoreCommand());
AddCommand(new ProjectBuildCommand());
AddCommand(new ProjectInitCommand());
AddCommand(new ProjectValidateCommand());
AddCommand(new ProjectReportCommand());
Add(new ProjectRestoreCommand());
Add(new ProjectBuildCommand());
Add(new ProjectInitCommand());
Add(new ProjectValidateCommand());
Add(new ProjectReportCommand());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ public SolutionCommand() : base("solution")
{
Description = "This command is used to manage solutions.";

AddCommand(new SolutionRestoreCommand());
AddCommand(new SolutionBuildCommand());
AddCommand(new SolutionInitCommand());
AddCommand(new SolutionValidateCommand());
Add(new SolutionRestoreCommand());
Add(new SolutionBuildCommand());
Add(new SolutionInitCommand());
Add(new SolutionValidateCommand());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public sealed class FromVariableNameOption : Option<string>
private FromVariableNameOption()
: base("--from")
{
IsRequired = false;
Required = false;
Description = "The name of the new variable";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public sealed class ToVariableNameOption : Option<string>
private ToVariableNameOption()
: base("--to")
{
IsRequired = false;
Required = false;
Description = "The name of the new variable";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public sealed class VariableNameOption : Option<string>
private VariableNameOption()
: base("--name")
{
IsRequired = false;
Required = false;
Description = "The name of the variable";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ private VariableProviderNameOption()
Arity = ArgumentArity.ExactlyOne;
Description = "The name of the provider to resolve the variable from";

AddAlias("-p");
Aliases.Add("-p");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public sealed class VariableValueOption : Option<string>
private VariableValueOption()
: base("--value")
{
IsRequired = false;
Required = false;
Description = "The value of the variable";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ public sealed class VariableCommand : Command
public VariableCommand() : base("variable")
{
Description = "This command is used to manage variables.";
AddCommand(new VariableGetCommand());
AddCommand(new VariableSetCommand());
AddCommand(new VariableListCommand());
AddCommand(new VariableCopyCommand());
Add(new VariableGetCommand());
Add(new VariableSetCommand());
Add(new VariableListCommand());
Add(new VariableCopyCommand());
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.CommandLine.Builder;
using System.CommandLine.Invocation;
using System.Runtime.CompilerServices;
using Confix.Extensions;
using Microsoft.Extensions.DependencyInjection;
Expand All @@ -8,56 +6,45 @@ namespace Confix.Tool;

public static class ContextDataCommandLineBuilderExtensions
{
private static readonly ConditionalWeakTable<CommandLineBuilder, ContextData> _contextData =
new();
private static readonly ConditionalWeakTable<ConfixCommandLineBuilder, ContextData>
_contextData = new();

public static CommandLineBuilder AddContextData(this CommandLineBuilder builder)
public static ConfixCommandLineBuilder AddContextData(this ConfixCommandLineBuilder builder)
{
var contextData = new ContextData();
// The same instance is shared between configuration time and invocation time so that
// values set while building the command line are visible to the running pipeline.
var contextData = _contextData.GetOrCreateValue(builder);
builder.AddSingleton(contextData);
_contextData.Add(builder, contextData);

return builder;
}

public static CommandLineBuilder SetContextData<T>(
this CommandLineBuilder builder,
public static ConfixCommandLineBuilder SetContextData<T>(
this ConfixCommandLineBuilder builder,
Context.Key<T> key,
T value)
where T : notnull
{
builder.AddMiddleware((context, next) =>
{
var data = context.BindingContext.GetRequiredService<ContextData>();
data.Data.Set(key, value);

return next(context);
});
_contextData.GetOrCreateValue(builder).Data.Set(key, value);

return builder;
}

public static IDictionary<string, object> GetContextData(this InvocationContext context)
{
return context.BindingContext.GetRequiredService<ContextData>().Data;
}
public static IDictionary<string, object> GetContextData(this IServiceProvider services)
=> services.GetRequiredService<ContextData>().Data;

public static IDictionary<string, object> GetContextData(this CommandLineBuilder builder)
{
return _contextData.GetOrCreateValue(builder).Data;
}
public static IDictionary<string, object> GetContextData(
this ConfixCommandLineBuilder builder)
=> _contextData.GetOrCreateValue(builder).Data;

public static void SetContextData<T>(
this InvocationContext context,
this IServiceProvider services,
in Context.Key<T> key,
T value)
where T : notnull
{
var data = context.BindingContext.GetRequiredService<ContextData>();
data.Data.Set(key, value);
}
=> services.GetRequiredService<ContextData>().Data.Set(key, value);

private class ContextData
internal class ContextData
{
public IDictionary<string, object> Data { get; } = new Dictionary<string, object>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void WriteTo(IAnsiConsole console)
// markup is by default not wrapped, so we need to add a newline
formatted += Environment.NewLine;

var markup = new Markup(formatted, Style ?? Style.Plain);
var markup = new Markup(formatted, Style ?? Spectre.Console.Style.Plain);

console.Write(markup);

Expand Down
Loading
Loading