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
10 changes: 7 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,17 @@ dotnet_remove_unnecessary_suppression_exclusions = none
#### C# Coding Conventions ####
[*.cs]
# analyzers
dotnet_diagnostic.IDE0290.severity = none # use primary constuctor
dotnet_diagnostic.IDE0290.severity = none # use primary constructor
dotnet_diagnostic.IDE0028.severity = none # use collection expression
dotnet_diagnostic.IDE0056.severity = none # simplify index operator
dotnet_diagnostic.IDE0057.severity = none # use range operator
dotnet_diagnostic.IDE0301.severity = none # simplify collection initialization
dotnet_diagnostic.IDE0053.severity = none # expression body lambda
dotnet_diagnostic.IDE0046.severity = none # simplify if(s) - conditional operator
dotnet_diagnostic.IDE0305.severity = none # [, ...] instead of .ToArray()

# namespace decleration

# namespace declaration
csharp_style_namespace_declarations = file_scoped:warning

# var preferences
Expand Down Expand Up @@ -369,4 +373,4 @@ dotnet_naming_style.camelcase.capitalization = camel_case
dotnet_naming_style.s_camelcase.required_prefix = s_
dotnet_naming_style.s_camelcase.required_suffix =
dotnet_naming_style.s_camelcase.word_separator =
dotnet_naming_style.s_camelcase.capitalization = camel_casel
dotnet_naming_style.s_camelcase.capitalization = camel_case
134 changes: 8 additions & 126 deletions .github/workflows/Tests.yaml
Original file line number Diff line number Diff line change
@@ -1,136 +1,18 @@
name: Tests

on:
push:
pull_request:
workflow_dispatch:

jobs:
test-sharpify:
runs-on: ${{ matrix.os }}
unit-tests:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
configuration: [Debug, Release]

env:
# Define the path to project and test project
PROJECT: src/Sharpify/Sharpify.csproj
TEST_PROJECT: tests/Sharpify.Tests/Sharpify.Tests.csproj

steps:
# 1. Checkout the repository code
- name: Checkout Repository
uses: actions/checkout@v4

# 2. Cache NuGet packages
- name: Cache NuGet Packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-

# 3. Setup .NET
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x

# 4. Clean
- name: Clean
run: |
dotnet clean ${{ env.PROJECT }} -c ${{ matrix.configuration }}
dotnet clean ${{ env.TEST_PROJECT }} -c ${{ matrix.configuration }}

# 5. Run Unit Tests
- name: Run Unit Tests
run: dotnet test ${{ env.TEST_PROJECT }} -c ${{ matrix.configuration }}

test-sharpify-data:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
configuration: [Debug, Release]

env:
# Define the path to project and test project
PROJECT: src/Sharpify.Data/Sharpify.Data.csproj
TEST_PROJECT: tests/Sharpify.Data.Tests/Sharpify.Data.Tests.csproj

steps:
# 1. Checkout the repository code
- name: Checkout Repository
uses: actions/checkout@v4

# 2. Cache NuGet packages
- name: Cache NuGet Packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-

# 3. Setup .NET
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x

# 4. Clean
- name: Clean
run: |
dotnet clean ${{ env.PROJECT }} -c ${{ matrix.configuration }}
dotnet clean ${{ env.TEST_PROJECT }} -c ${{ matrix.configuration }}

# 5. Run Unit Tests
- name: Run Unit Tests
run: dotnet test ${{ env.TEST_PROJECT }} -c ${{ matrix.configuration }}

test-sharpify-cli:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
configuration: [Debug, Release]

env:
# Define the path to project and test project
PROJECT: src/Sharpify.CommandLineInterface/Sharpify.CommandLineInterface.csproj
TEST_PROJECT: tests/Sharpify.CommandLineInterface.Tests/Sharpify.CommandLineInterface.Tests.csproj

steps:
# 1. Checkout the repository code
- name: Checkout Repository
uses: actions/checkout@v4

# 2. Cache NuGet packages
- name: Cache NuGet Packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-

# 3. Setup .NET
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x

# 4. Clean
- name: Clean
run: |
dotnet clean ${{ env.PROJECT }} -c ${{ matrix.configuration }}
dotnet clean ${{ env.TEST_PROJECT }} -c ${{ matrix.configuration }}

# 5. Run Unit Tests
- name: Run Unit Tests
run: dotnet test ${{ env.TEST_PROJECT }} -c ${{ matrix.configuration }}
platform: [ubuntu-latest, windows-latest, macos-latest]
project: [tests/Sharpify.Tests/Sharpify.Tests.csproj, tests/Sharpify.CommandLineInterface.Tests/Sharpify.CommandLineInterface.Tests.csproj]
uses: dusrdev/actions/.github/workflows/reusable-dotnet-test-mtp.yaml@main
with:
platform: ${{ matrix.platform }}
dotnet-version: 9.0.x
test-project-path: ${{ matrix.project }}
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ A collection of high performance language extensions for C#, fully compatible wi
[![Nuget](https://img.shields.io/nuget/dt/Sharpify.Data?label=Sharpify.Data%20Nuget%20Downloads)](https://www.nuget.org/packages/Sharpify.Data/)
> dotnet add package Sharpify.Data

* `Sharpify.Data` is deprecated and will no longer be maintained. Refer to [ArrowDb](https://github.com/dusrdev/ArrowDb) for a superior alternative.

[![Nuget](https://img.shields.io/nuget/dt/Sharpify.CommandLineInterface?label=Sharpify.CommandLineInterface%20Nuget%20Downloads)](https://www.nuget.org/packages/Sharpify.CommandLineInterface/)
> dotnet add package Sharpify.CommandLineInterface

Expand Down Expand Up @@ -57,12 +59,12 @@ For more information check [inner directory](src/Sharpify.Data/README.md).

## Sharpify.CommandLineInterface

`Sharpify.CommandLineInterface` is another extension package that adds a high performance, reflection free and `AOT-ready` framework for creating command line and embedded interfaces
`Sharpify.CommandLineInterface` is a standalone package that adds a high performance, reflection free and `AOT-ready` framework for creating command line and embedded interfaces

* Maintenance friendly model that depends on class that implement `Command` or `SynchronousCommand`
* Maintenance friendly model that depends on classes that implement `Command` or `SynchronousCommand`
* `Arguments` is an abstraction layer over the inputs that validate during runtime according to user needs via convenient APIs.
* Configuration using a fluent builder pattern.
* Configurable output and input pipes, enable usage outside of `Console` apps, enabling the option for embedded use in any application.
* Configurable output and input pipes, enable usage outside of `Console` apps, supporting embedded use in any application.
* Automatic and structured general and command-specific help text.
* Configurable error handling with defaults.
* Super lightweight
Expand Down
59 changes: 0 additions & 59 deletions Sharpify.sln

This file was deleted.

6 changes: 6 additions & 0 deletions Sharpify.slnx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Solution>
<Project Path="src/Sharpify.CommandLineInterface/Sharpify.CommandLineInterface.csproj" />
<Project Path="src/Sharpify/Sharpify.csproj" />
<Project Path="tests/Sharpify.CommandLineInterface.Tests/Sharpify.CommandLineInterface.Tests.csproj" />
<Project Path="tests/Sharpify.Tests/Sharpify.Tests.csproj" />
</Solution>
26 changes: 0 additions & 26 deletions build.sh

This file was deleted.

38 changes: 10 additions & 28 deletions src/Sharpify.CommandLineInterface/ArgumentsCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,19 @@ namespace Sharpify.CommandLineInterface;
/// Arguments instances are created via <see cref="Parser"/>
/// </remarks>
public sealed partial class Arguments {
private readonly string[] _args;
/// <summary>
/// Source is the list of separated arguments on top of which this instance of <see cref="Arguments"/> was built.
/// </summary>
public readonly ReadOnlyCollection<string> Source;
private readonly Dictionary<string, string> _arguments;

/// <summary>
/// Internal constructor for the <see cref="Arguments"/> class
/// </summary>
/// <param name="args">Copy or reference of the arguments before processing</param>
/// <param name="arguments">Ensure not null or empty</param>
internal Arguments(string[] args, Dictionary<string, string> arguments) {
_args = args;
internal Arguments(ReadOnlyCollection<string> args, Dictionary<string, string> arguments) {
Source = args;
_arguments = arguments;
}

Expand All @@ -35,33 +38,12 @@ internal Arguments(string[] args, Dictionary<string, string> arguments) {
/// <summary>
/// Returns an empty arguments object.
/// </summary>
public static readonly Arguments Empty = new([], []);
public static readonly Arguments Empty = new(Array.Empty<string>().AsReadOnly(), []);

/// <summary>
/// Returns a <see cref="ReadOnlyMemory{String}"/> of the arguments as they were before processing, but after splitting (if it was required)
/// Returns an array copy of <see cref="Source"/>
/// </summary>
/// <remarks>
/// <para>
/// If you passed a collection of strings to be used for <see cref="Arguments"/> it will contain a copy of that array, if a <see cref="string"/> was passed, it will contain a copy of the result of <see cref="Parser.ParseArguments(ReadOnlySpan{char})"/>
/// </para>
/// <para>
/// In normal use case you shouldn't need this, but in case you want to manufacture some sort of a nested command structure, you can use this to filter once more for <see cref="Arguments"/> after selectively parsing some of the arguments, in which case it is very powerful.
/// </para>
/// </remarks>
public ReadOnlyMemory<string> ArgsAsMemory() => _args;

/// <summary>
/// Returns a <see cref="ReadOnlySpan{String}"/> of the arguments as they were before processing, but after splitting (if it was required)
/// </summary>
/// <remarks>
/// <para>
/// If you passed a collection of strings to be used for <see cref="Arguments"/> it will contain a copy of that array, if a <see cref="string"/> was passed, it will contain a copy of the result of <see cref="Parser.ParseArguments(ReadOnlySpan{char})"/>
/// </para>
/// <para>
/// In normal use case you shouldn't need this, but in case you want to manufacture some sort of a nested command structure, you can use this to filter once more for <see cref="Arguments"/> after selectively parsing some of the arguments, in which case it is very powerful.
/// </para>
/// </remarks>
public ReadOnlySpan<string> ArgsAsSpan() => _args;
public string[] SourceCopy => Source.ToArray();

/// <summary>
/// Returns new Arguments with positional arguments forwarded by 1, so that argument that was 1 is now 0, 2 is now 1 and so on. This is non-destructive, the original arguments are not modified.
Expand Down Expand Up @@ -94,7 +76,7 @@ public Arguments ForwardPositionalArguments() {

// Because this is a new dictionary, if pos 1, isn't found, 0 still won't be present
// So essentially 0 was forwarded to no longer exist
return new Arguments(_args, dict);
return new Arguments(Source, dict);
}

/// <summary>
Expand Down
Loading
Loading