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
6 changes: 3 additions & 3 deletions src/Ubiquity.NET.CommandLine/ArgsParsing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,21 +185,21 @@ out int exitCode
return true;
}

/// <inheritdoc cref="TryParse{T}(string[], CmdLineSettings?, IDiagnosticReporter, out T)"/>
/// <inheritdoc cref="TryParse{T}(string[], CmdLineSettings?, IDiagnosticReporter, out T, out int)"/>
public static bool TryParse<T>( string[] args, CmdLineSettings settings, [MaybeNullWhen( false )] out T boundValue, out int exitCode )
where T : IRootCommand<T>
{
return TryParse<T>( args, settings, new ConsoleReporter( MsgLevel.Information ), out boundValue, out exitCode );
}

/// <inheritdoc cref="TryParse{T}(string[], CmdLineSettings?, IDiagnosticReporter, out T)"/>
/// <inheritdoc cref="TryParse{T}(string[], CmdLineSettings?, IDiagnosticReporter, out T, out int)"/>
public static bool TryParse<T>( string[] args, [MaybeNullWhen( false )] out T boundValue, out int exitCode )
where T : IRootCommand<T>
{
return TryParse<T>( args, settings: null, new ConsoleReporter( MsgLevel.Information ), out boundValue, out exitCode );
}

/// <inheritdoc cref="TryParse{T}(string[], CmdLineSettings?, IDiagnosticReporter, out T)"/>
/// <inheritdoc cref="TryParse{T}(string[], CmdLineSettings?, IDiagnosticReporter, out T, out int)"/>
public static bool TryParse<T>( string[] args, IDiagnosticReporter diagnosticReporter, [MaybeNullWhen( false )] out T boundValue, out int exitCode )
where T : IRootCommand<T>
{
Expand Down
20 changes: 20 additions & 0 deletions src/Ubiquity.NET.CommandLine/PackageReadMe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Ubiquity.NET.CommandLine
Command line parsing support extending System.CommandLine to better isolate the parsing
from the app specific validation and execution.

``` C#
var reporter = new ColoredConsoleReporter(MsgLevel.Information);
if(!ArgsParsing.TryParse<Options>( args, reporter, out Options? options, out int exitCode ))
{
return exitCode;
}

// ...

// Options is a class that has properties for all parsed commands, arguments and options
// Allowing for validation of them all in context (including each other)
// App can then dispatch behavior based on the commands/options etc... as needed.
// NO ASSUMPTION IS MADE ABOUT THE USE OF COMMANDS NOR THE BEHAVIOR OF THEM. The app
// is entirely in control of how they are used.

```
54 changes: 37 additions & 17 deletions src/Ubiquity.NET.CommandLine/Ubiquity.NET.CommandLine.csproj
Original file line number Diff line number Diff line change
@@ -1,23 +1,43 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<!--Until C#14 and the "field" and "extensions" keywords are available use the preview language -->
<LangVersion>preview</LangVersion>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<!--Until C#14 and the "field" and "extensions" keywords are available use the preview language -->
<LangVersion>preview</LangVersion>
<GenerateDocumentationFile>True</GenerateDocumentationFile>

<ItemGroup>
<PackageReference Include="PolySharp">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.CommandLine" />
</ItemGroup>
<!--NuGet packaging support -->
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<MinClientVersion>4.9.0</MinClientVersion>
<Authors>.NET Foundation,Ubiquity.NET</Authors>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<Description>General use Support for Command line parsing based on System.CommandLine</Description>
<PackageTags>Extensions,.NET,Ubiquity.NET, Console</PackageTags>
<PackageReadmeFile>PackageReadMe.md</PackageReadmeFile>
<PackageProjectUrl>https://github.com/UbiquityDotNET/Llvm.NET</PackageProjectUrl>
<RepositoryUrl>https://github.com/UbiquityDotNET/Llvm.NET.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageLicenseExpression>Apache-2.0 WITH LLVM-exception</PackageLicenseExpression>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Ubiquity.NET.Extensions\Ubiquity.NET.Extensions.csproj" />
<ProjectReference Include="..\Ubiquity.NET.TextUX\Ubiquity.NET.TextUX.csproj" />
</ItemGroup>
<ItemGroup>
<None Include="PackageReadMe.md" Pack="true" PackagePath="\" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="PolySharp">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.CommandLine" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Ubiquity.NET.Extensions\Ubiquity.NET.Extensions.csproj" />
<ProjectReference Include="..\Ubiquity.NET.TextUX\Ubiquity.NET.TextUX.csproj" />
</ItemGroup>

</Project>
168 changes: 0 additions & 168 deletions src/Ubiquity.NET.Extensions/PolyFillExtensions.cs

This file was deleted.

Loading