Skip to content

Commit 82c2cf0

Browse files
authored
Merge pull request #18 from dusrdev/pre-release
Updated Sharpify.CommandLineInterface to version 2.0.0
2 parents c30356c + 7342fe8 commit 82c2cf0

26 files changed

Lines changed: 341 additions & 495 deletions

.editorconfig

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,17 @@ dotnet_remove_unnecessary_suppression_exclusions = none
7777
#### C# Coding Conventions ####
7878
[*.cs]
7979
# analyzers
80-
dotnet_diagnostic.IDE0290.severity = none # use primary constuctor
80+
dotnet_diagnostic.IDE0290.severity = none # use primary constructor
8181
dotnet_diagnostic.IDE0028.severity = none # use collection expression
8282
dotnet_diagnostic.IDE0056.severity = none # simplify index operator
8383
dotnet_diagnostic.IDE0057.severity = none # use range operator
8484
dotnet_diagnostic.IDE0301.severity = none # simplify collection initialization
85+
dotnet_diagnostic.IDE0053.severity = none # expression body lambda
86+
dotnet_diagnostic.IDE0046.severity = none # simplify if(s) - conditional operator
87+
dotnet_diagnostic.IDE0305.severity = none # [, ...] instead of .ToArray()
8588

86-
# namespace decleration
89+
90+
# namespace declaration
8791
csharp_style_namespace_declarations = file_scoped:warning
8892

8993
# var preferences
@@ -369,4 +373,4 @@ dotnet_naming_style.camelcase.capitalization = camel_case
369373
dotnet_naming_style.s_camelcase.required_prefix = s_
370374
dotnet_naming_style.s_camelcase.required_suffix =
371375
dotnet_naming_style.s_camelcase.word_separator =
372-
dotnet_naming_style.s_camelcase.capitalization = camel_casel
376+
dotnet_naming_style.s_camelcase.capitalization = camel_case

.github/workflows/Tests.yaml

Lines changed: 8 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -1,136 +1,18 @@
11
name: Tests
22

33
on:
4-
push:
54
pull_request:
65
workflow_dispatch:
76

87
jobs:
9-
test-sharpify:
10-
runs-on: ${{ matrix.os }}
8+
unit-tests:
119
strategy:
1210
fail-fast: false
1311
matrix:
14-
os: [ubuntu-latest, windows-latest, macos-latest]
15-
configuration: [Debug, Release]
16-
17-
env:
18-
# Define the path to project and test project
19-
PROJECT: src/Sharpify/Sharpify.csproj
20-
TEST_PROJECT: tests/Sharpify.Tests/Sharpify.Tests.csproj
21-
22-
steps:
23-
# 1. Checkout the repository code
24-
- name: Checkout Repository
25-
uses: actions/checkout@v4
26-
27-
# 2. Cache NuGet packages
28-
- name: Cache NuGet Packages
29-
uses: actions/cache@v4
30-
with:
31-
path: ~/.nuget/packages
32-
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
33-
restore-keys: |
34-
${{ runner.os }}-nuget-
35-
36-
# 3. Setup .NET
37-
- name: Setup .NET
38-
uses: actions/setup-dotnet@v4
39-
with:
40-
dotnet-version: 9.0.x
41-
42-
# 4. Clean
43-
- name: Clean
44-
run: |
45-
dotnet clean ${{ env.PROJECT }} -c ${{ matrix.configuration }}
46-
dotnet clean ${{ env.TEST_PROJECT }} -c ${{ matrix.configuration }}
47-
48-
# 5. Run Unit Tests
49-
- name: Run Unit Tests
50-
run: dotnet test ${{ env.TEST_PROJECT }} -c ${{ matrix.configuration }}
51-
52-
test-sharpify-data:
53-
runs-on: ${{ matrix.os }}
54-
strategy:
55-
fail-fast: false
56-
matrix:
57-
os: [ubuntu-latest, windows-latest, macos-latest]
58-
configuration: [Debug, Release]
59-
60-
env:
61-
# Define the path to project and test project
62-
PROJECT: src/Sharpify.Data/Sharpify.Data.csproj
63-
TEST_PROJECT: tests/Sharpify.Data.Tests/Sharpify.Data.Tests.csproj
64-
65-
steps:
66-
# 1. Checkout the repository code
67-
- name: Checkout Repository
68-
uses: actions/checkout@v4
69-
70-
# 2. Cache NuGet packages
71-
- name: Cache NuGet Packages
72-
uses: actions/cache@v4
73-
with:
74-
path: ~/.nuget/packages
75-
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
76-
restore-keys: |
77-
${{ runner.os }}-nuget-
78-
79-
# 3. Setup .NET
80-
- name: Setup .NET
81-
uses: actions/setup-dotnet@v4
82-
with:
83-
dotnet-version: 9.0.x
84-
85-
# 4. Clean
86-
- name: Clean
87-
run: |
88-
dotnet clean ${{ env.PROJECT }} -c ${{ matrix.configuration }}
89-
dotnet clean ${{ env.TEST_PROJECT }} -c ${{ matrix.configuration }}
90-
91-
# 5. Run Unit Tests
92-
- name: Run Unit Tests
93-
run: dotnet test ${{ env.TEST_PROJECT }} -c ${{ matrix.configuration }}
94-
95-
test-sharpify-cli:
96-
runs-on: ${{ matrix.os }}
97-
strategy:
98-
fail-fast: false
99-
matrix:
100-
os: [ubuntu-latest, windows-latest, macos-latest]
101-
configuration: [Debug, Release]
102-
103-
env:
104-
# Define the path to project and test project
105-
PROJECT: src/Sharpify.CommandLineInterface/Sharpify.CommandLineInterface.csproj
106-
TEST_PROJECT: tests/Sharpify.CommandLineInterface.Tests/Sharpify.CommandLineInterface.Tests.csproj
107-
108-
steps:
109-
# 1. Checkout the repository code
110-
- name: Checkout Repository
111-
uses: actions/checkout@v4
112-
113-
# 2. Cache NuGet packages
114-
- name: Cache NuGet Packages
115-
uses: actions/cache@v4
116-
with:
117-
path: ~/.nuget/packages
118-
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
119-
restore-keys: |
120-
${{ runner.os }}-nuget-
121-
122-
# 3. Setup .NET
123-
- name: Setup .NET
124-
uses: actions/setup-dotnet@v4
125-
with:
126-
dotnet-version: 9.0.x
127-
128-
# 4. Clean
129-
- name: Clean
130-
run: |
131-
dotnet clean ${{ env.PROJECT }} -c ${{ matrix.configuration }}
132-
dotnet clean ${{ env.TEST_PROJECT }} -c ${{ matrix.configuration }}
133-
134-
# 5. Run Unit Tests
135-
- name: Run Unit Tests
136-
run: dotnet test ${{ env.TEST_PROJECT }} -c ${{ matrix.configuration }}
12+
platform: [ubuntu-latest, windows-latest, macos-latest]
13+
project: [tests/Sharpify.Tests/Sharpify.Tests.csproj, tests/Sharpify.CommandLineInterface.Tests/Sharpify.CommandLineInterface.Tests.csproj]
14+
uses: dusrdev/actions/.github/workflows/reusable-dotnet-test-mtp.yaml@main
15+
with:
16+
platform: ${{ matrix.platform }}
17+
dotnet-version: 9.0.x
18+
test-project-path: ${{ matrix.project }}

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ A collection of high performance language extensions for C#, fully compatible wi
1010
[![Nuget](https://img.shields.io/nuget/dt/Sharpify.Data?label=Sharpify.Data%20Nuget%20Downloads)](https://www.nuget.org/packages/Sharpify.Data/)
1111
> dotnet add package Sharpify.Data
1212
13+
* `Sharpify.Data` is deprecated and will no longer be maintained. Refer to [ArrowDb](https://github.com/dusrdev/ArrowDb) for a superior alternative.
14+
1315
[![Nuget](https://img.shields.io/nuget/dt/Sharpify.CommandLineInterface?label=Sharpify.CommandLineInterface%20Nuget%20Downloads)](https://www.nuget.org/packages/Sharpify.CommandLineInterface/)
1416
> dotnet add package Sharpify.CommandLineInterface
1517
@@ -57,12 +59,12 @@ For more information check [inner directory](src/Sharpify.Data/README.md).
5759

5860
## Sharpify.CommandLineInterface
5961

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

62-
* Maintenance friendly model that depends on class that implement `Command` or `SynchronousCommand`
64+
* Maintenance friendly model that depends on classes that implement `Command` or `SynchronousCommand`
6365
* `Arguments` is an abstraction layer over the inputs that validate during runtime according to user needs via convenient APIs.
6466
* Configuration using a fluent builder pattern.
65-
* Configurable output and input pipes, enable usage outside of `Console` apps, enabling the option for embedded use in any application.
67+
* Configurable output and input pipes, enable usage outside of `Console` apps, supporting embedded use in any application.
6668
* Automatic and structured general and command-specific help text.
6769
* Configurable error handling with defaults.
6870
* Super lightweight

Sharpify.sln

Lines changed: 0 additions & 59 deletions
This file was deleted.

Sharpify.slnx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<Solution>
2+
<Project Path="src/Sharpify.CommandLineInterface/Sharpify.CommandLineInterface.csproj" />
3+
<Project Path="src/Sharpify/Sharpify.csproj" />
4+
<Project Path="tests/Sharpify.CommandLineInterface.Tests/Sharpify.CommandLineInterface.Tests.csproj" />
5+
<Project Path="tests/Sharpify.Tests/Sharpify.Tests.csproj" />
6+
</Solution>

build.sh

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/Sharpify.CommandLineInterface/ArgumentsCore.cs

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,19 @@ namespace Sharpify.CommandLineInterface;
99
/// Arguments instances are created via <see cref="Parser"/>
1010
/// </remarks>
1111
public sealed partial class Arguments {
12-
private readonly string[] _args;
12+
/// <summary>
13+
/// Source is the list of separated arguments on top of which this instance of <see cref="Arguments"/> was built.
14+
/// </summary>
15+
public readonly ReadOnlyCollection<string> Source;
1316
private readonly Dictionary<string, string> _arguments;
1417

1518
/// <summary>
1619
/// Internal constructor for the <see cref="Arguments"/> class
1720
/// </summary>
1821
/// <param name="args">Copy or reference of the arguments before processing</param>
1922
/// <param name="arguments">Ensure not null or empty</param>
20-
internal Arguments(string[] args, Dictionary<string, string> arguments) {
21-
_args = args;
23+
internal Arguments(ReadOnlyCollection<string> args, Dictionary<string, string> arguments) {
24+
Source = args;
2225
_arguments = arguments;
2326
}
2427

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

4043
/// <summary>
41-
/// Returns a <see cref="ReadOnlyMemory{String}"/> of the arguments as they were before processing, but after splitting (if it was required)
44+
/// Returns an array copy of <see cref="Source"/>
4245
/// </summary>
43-
/// <remarks>
44-
/// <para>
45-
/// 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})"/>
46-
/// </para>
47-
/// <para>
48-
/// 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.
49-
/// </para>
50-
/// </remarks>
51-
public ReadOnlyMemory<string> ArgsAsMemory() => _args;
52-
53-
/// <summary>
54-
/// Returns a <see cref="ReadOnlySpan{String}"/> of the arguments as they were before processing, but after splitting (if it was required)
55-
/// </summary>
56-
/// <remarks>
57-
/// <para>
58-
/// 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})"/>
59-
/// </para>
60-
/// <para>
61-
/// 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.
62-
/// </para>
63-
/// </remarks>
64-
public ReadOnlySpan<string> ArgsAsSpan() => _args;
46+
public string[] SourceCopy => Source.ToArray();
6547

6648
/// <summary>
6749
/// 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.
@@ -94,7 +76,7 @@ public Arguments ForwardPositionalArguments() {
9476

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

10082
/// <summary>

0 commit comments

Comments
 (0)