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: 2 additions & 4 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@
]
},
"dotnet-reportgenerator-globaltool": {
"version": "5.2.1",
"commands": [
"reportgenerator"
]
"version": "5.2.2",
"commands": ["reportgenerator"]
}
}
}
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: CI and docs

env:
ACTIONS_RUNNER_NODE16: true
ACTIONS_RUNNER_NODE20: true

on:
push:
Expand All @@ -14,13 +14,13 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
- name: Restore dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
Expand All @@ -41,7 +41,7 @@ jobs:
- name: Convert coverage report to lcov format
run: reportgenerator "-reports:./coverage.opencover.xml" "-targetdir:coverage" "-reporttypes:lcov"
- name: Coveralls upload
uses: coverallsapp/github-action@master
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./coverage/lcov.info
Expand All @@ -52,9 +52,9 @@ jobs:
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
- name: Build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Set VERSION variable from tag
run: echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_ENV
- name: Build
run: dotnet build --configuration Release /p:Version=${VERSION}
run: dotnet build -c Release /p:Version=${VERSION} /p:ContinuousIntegrationBuild=true
- name: Pack
run: dotnet pack src/ConsoleAppVisuals/ConsoleAppVisuals.csproj --configuration Release /p:ContinuousIntegrationBuild=true /p:Version=${VERSION} --no-build --output .
- name: Push to GitHub Packages
Expand Down
22 changes: 9 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

> User-friendly .NET visuals library designed for console apps

[![version](https://img.shields.io/nuget/v/ConsoleAppVisuals.svg?label=version)](https://www.nuget.org/packages/ConsoleAppVisuals/) [![NuGet](https://img.shields.io/nuget/dt/ConsoleAppVisuals.svg)](https://www.nuget.org/packages/ConsoleAppVisuals/) [![GitHub](https://img.shields.io/github/stars/MorganKryze/consoleappvisuals.svg?style=flat&logo=github&colorB=yellow&label=stars)](https://github.com/MorganKryze/ConsoleAppVisuals) [![Coverage Status](https://coveralls.io/repos/github/MorganKryze/ConsoleAppVisuals/badge.svg?)](https://coveralls.io/github/MorganKryze/ConsoleAppVisuals?branch=main) [![License: GNU GPL](https://img.shields.io/badge/License-GNU_GPL-orange.svg)](https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/LICENSE)
[![version](https://img.shields.io/nuget/v/ConsoleAppVisuals.svg?label=version)](https://www.nuget.org/packages/ConsoleAppVisuals/) [![NuGet](https://img.shields.io/nuget/dt/ConsoleAppVisuals.svg)](https://www.nuget.org/packages/ConsoleAppVisuals/) [![GitHub](https://img.shields.io/github/stars/MorganKryze/consoleappvisuals.svg?style=flat&logo=github&colorB=yellow&label=stars)](https://github.com/MorganKryze/ConsoleAppVisuals) [![Coverage Status](https://coveralls.io/repos/github/MorganKryze/ConsoleAppVisuals/badge.svg?)](https://coveralls.io/github/MorganKryze/ConsoleAppVisuals?branch=main) [![License: GNU GPL](https://img.shields.io/badge/License-GNU_GPL-orange.svg)](https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/LICENSE) [![Lines Of Code](https://tokei.rs/b1/github/MorganKryze/ConsoleAppVisuals)](https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/src/ConsoleAppVisuals)

![title](docs/assets/vid/gif/presentation.gif)

## Documentation

Feel free to check out the following resources to help you get started:

- Take a quick look at our [example project](https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs) to understand how to implement the library in your own project
- Take a quick look at our [example project](https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/) to understand how to implement the library in your own project
- A [complete documentation](https://morgankryze.github.io/ConsoleAppVisuals/) is also available.

## Install
Expand Down Expand Up @@ -51,6 +51,7 @@ After installing the library, do not forget to add the following statement at th

```csharp
using ConsoleAppVisuals;
using ConsoleAppVisuals.Elements;
```

#### Work with static elements
Expand All @@ -73,20 +74,15 @@ Finally, you can display the `Window`:
Window.Render();
```

Now at each refresh, the `Title` element will appear on screen. To disable it, you may choose one of these options:
Now at each refresh, the `Title` element will appear on screen. To disable it, you can use:

```csharp
// Will look for a Title element and deactivate it, the first on the list
Window.DeactivateElement<Title>();

// Will deactivate the exampleTitle element
Window.DeactivateElement(exampleTitle);
```

Or simply remove it from the list:

```csharp
Window.RemoveElement<Title>();
Window.RemoveElement(exampleTitle);
```

Expand All @@ -95,7 +91,7 @@ Window.RemoveElement(exampleTitle);
The process is similar to the static elements. The difference is that you can get a response from your interaction with these elements. Let's create a `Prompt` element:

```csharp
Prompt examplePrompt = new Prompt("What is your name?", "Theo");
Prompt examplePrompt = new Prompt("What is your name?");
```

Then, you can add it to `Window`:
Expand All @@ -110,13 +106,13 @@ Finally, you can display the `Window`, remember that interactive element are dis
// Add this line if you have static elements to display
Window.Render();

Window.ActivateElement<Prompt>();
Window.ActivateElement(examplePrompt);
```

To get the response simply add:

```csharp
var responsePrompt = Window.GetResponse<Prompt, string>();
var responsePrompt = examplePrompt.GetResponse();
```

Access to the response data using:
Expand All @@ -130,12 +126,12 @@ Console.WriteLine(responsePrompt?.Info);
```

> [!NOTE]
> Getting the response from an interactive element will automatically deactivate it.
> The `InteractiveElement` object deactivate themselves after their execution.

You may now remove the element from the list if you want to:

```csharp
Window.RemoveElement<Prompt>();
Window.RemoveElement(examplePrompt);
```

## Roadmap
Expand Down
3 changes: 2 additions & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

| Version | Supported |
| ------- | ------------------ |
| 3.1.x | :warning: |
| 3.0.x | :warning: |
| 2.7.x | :white_check_mark: |
| 2.6.x | :white_check_mark: |
Expand All @@ -14,7 +15,7 @@
| 2.1.x | :white_check_mark: |
| < 2.1.0 | :x: |

3.0.x are the latest versions. They are not fully tested yet and may contain some bugs. Please report any issue you may encounter.
3.0.x and 3.0.x are the latest versions. They are not fully tested yet and may contain some bugs. Please report any issue you may encounter.

1.0.x and 2.0.x are not supported anymore. Please update to the latest version to benefit from the latest security updates.

Expand Down
24 changes: 12 additions & 12 deletions docs/articles/create_element.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,26 +172,26 @@ Once your customization is done, you may use your element in your application ju
Now that you know how to create your own elements, you can check if they are available in the library. To do so, you can use built-in elements to display all the elements available in the library (available in the [example project](https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/InteractiveDemo.cs)). Here is an example of how to do it:

```csharp
ElementsList list = new();
Window.AddElement(list);
ElementsList elementList = new ElementsList();
Window.AddElement(elementList);


Window.Render();
Window.StopExecution();
Window.Render(elementList);
Window.Freeze();

Window.Clear();
Window.RemoveElement(list);
Window.DeactivateElement(elementList);
Window.RemoveElement(elementList);
```

Or target only interactive elements:

```csharp
InteractiveList list = new();
Window.AddElement(list);
InteractiveList interactiveList = new InteractiveList();
Window.AddElement(interactiveList);

Window.Render();
Window.StopExecution();
Window.Render(interactiveList);
Window.Freeze();

Window.Clear();
Window.RemoveElement(list);
Window.DeactivateElement(interactiveList);
Window.RemoveElement(interactiveList);
```
17 changes: 9 additions & 8 deletions docs/articles/publish_library.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ Here is a template for a `.csproj` file made for publishing a package:
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<!-- MANDATORY: add your metadata comments to your package -->
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<PropertyGroup>
Expand All @@ -110,15 +112,15 @@ Here is a template for a `.csproj` file made for publishing a package:
<RepositoryType>git</RepositoryType>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<!-- MANDATORY: add your metadata comments to your package -->
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<!-- This line make your package deterministic -->
<EmbedUntrackedSources>true</EmbedUntrackedSources>
</PropertyGroup>

<!-- This code block make your package deterministic -->
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
<PropertyGroup>
<!-- NuGet Package Explorer health standards -->
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<IncludeSymbols>true</IncludeSymbols>
</PropertyGroup>

<ItemGroup>
Expand Down Expand Up @@ -210,7 +212,7 @@ jobs:
- name: Set VERSION variable from tag
run: echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_ENV
- name: Build
run: dotnet build --configuration Release /p:Version=${VERSION}
run: dotnet build --configuration Release /p:ContinuousIntegrationBuild=true /p:Version=${VERSION}
- name: Pack
run: dotnet pack <your_path_from_your_project_file> --configuration Release /p:ContinuousIntegrationBuild=true /p:Version=${VERSION} --no-build --output .
- name: Push to GitHub Packages
Expand Down Expand Up @@ -242,7 +244,6 @@ If that project was indeed for you for demo purposes, you cannot delete it from
## Resources

- [Official NuGet documentation](https://learn.microsoft.com/nuget/quickstart/create-and-publish-a-package-using-the-dotnet-cli)

- [Main Source](https://acraven.medium.com/a-nuget-package-workflow-using-github-actions-7da8c6557863)

- [Recap](https://levelup.gitconnected.com/publish-to-nuget-with-github-actions-4e1486e7c19f)
- [Deterministic Builds](https://github.com/clairernovotny/DeterministicBuilds)
6 changes: 0 additions & 6 deletions docs/elements/first_element.md

This file was deleted.

6 changes: 0 additions & 6 deletions docs/elements/index.md

This file was deleted.

5 changes: 0 additions & 5 deletions docs/elements/toc.yml

This file was deleted.

11 changes: 5 additions & 6 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ConsoleAppVisuals

[![version](https://img.shields.io/nuget/v/ConsoleAppVisuals.svg?label=version)](https://www.nuget.org/packages/ConsoleAppVisuals/) [![NuGet](https://img.shields.io/nuget/dt/ConsoleAppVisuals.svg)](https://www.nuget.org/packages/ConsoleAppVisuals/) [![GitHub](https://img.shields.io/github/stars/MorganKryze/consoleappvisuals.svg?style=flat&logo=github&colorB=yellow&label=stars)](https://github.com/MorganKryze/ConsoleAppVisuals) [![Coverage Status](https://coveralls.io/repos/github/MorganKryze/ConsoleAppVisuals/badge.svg?branch=main)](https://coveralls.io/github/MorganKryze/ConsoleAppVisuals?branch=main)[![License: GNU GPL](https://img.shields.io/badge/License-GNU_GPL-orange.svg)](https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/LICENSE)
[![version](https://img.shields.io/nuget/v/ConsoleAppVisuals.svg?label=version)](https://www.nuget.org/packages/ConsoleAppVisuals/) [![NuGet](https://img.shields.io/nuget/dt/ConsoleAppVisuals.svg)](https://www.nuget.org/packages/ConsoleAppVisuals/) [![GitHub](https://img.shields.io/github/stars/MorganKryze/consoleappvisuals.svg?style=flat&logo=github&colorB=yellow&label=stars)](https://github.com/MorganKryze/ConsoleAppVisuals) [![Coverage Status](https://coveralls.io/repos/github/MorganKryze/ConsoleAppVisuals/badge.svg?branch=main)](https://coveralls.io/github/MorganKryze/ConsoleAppVisuals?branch=main)[![License: GNU GPL](https://img.shields.io/badge/License-GNU_GPL-orange.svg)](https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/LICENSE) [![Lines Of Code](https://tokei.rs/b1/github/MorganKryze/ConsoleAppVisuals)](https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/src/ConsoleAppVisuals)

![presentation](assets/vid/gif/presentation.gif)

Expand All @@ -9,12 +9,11 @@
This is the documentation for the `ConsoleAppVisuals` library. This is a simple and easy-to-use library that allows you to create visual elements in the console. Here are all the resources available:

1. [Introduction](/ConsoleAppVisuals/introduction/index.html): find the installation process, the first steps into the library and the description of the `Core` and `Window` classes.
2. [Elements](/ConsoleAppVisuals/elements/index.html): find the detailed features of the visual elements available and recommendations.
3. [References](/ConsoleAppVisuals/references/index.html): find all methods, properties and classes with their description and all arguments available.
4. [Articles](/ConsoleAppVisuals/articles/index.html): find some additional articles about how to create and publish a library or create your documentation.
5. [Legacy](/ConsoleAppVisuals/legacy/index.html): find the old documentation of the library for the versions 2.x.x and below.
2. [References](/ConsoleAppVisuals/references/index.html): find all methods, properties and classes with their description and all arguments available.
3. [Articles](/ConsoleAppVisuals/articles/index.html): find some additional articles about how to create and publish a library or create your documentation.
4. [Legacy](/ConsoleAppVisuals/legacy/index.html): find the old documentation of the library for the versions 2.x.x and below.

Finally, an commented [example project](https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs) to see how to use the library in a real project. If you have any questions, feel free to ask them in the [discussions](https://github.com/MorganKryze/ConsoleAppVisuals/discussions) section.
Finally, an commented [example project](https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/) to see how to use the library in a real project. If you have any questions, feel free to ask them in the [discussions](https://github.com/MorganKryze/ConsoleAppVisuals/discussions) section.

## Supported .NET versions

Expand Down
15 changes: 8 additions & 7 deletions docs/introduction/first_app.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ Now, let's add the `ConsoleAppVisuals` package to our project:
```csharp
using System;
using ConsoleAppVisuals;
using ConsoleAppVisuals.Elements;

namespace MyApp
{
Expand All @@ -105,7 +106,7 @@ Window.AddElement(title);
And finally, we can render the `Title` from the `Window`:

```csharp
Window.RenderOneElement(title);
Window.Render(title);
```

![Title](../assets/img/jpg/first_app/title.jpg)
Expand Down Expand Up @@ -158,7 +159,7 @@ Window.ActivateElement(prompt);
Now that we have well displayed the prompt, we can get the user's response by adding the following line of code after the `Window.ActivateElement(prompt)` line:

```csharp
var response = Window.GetResponse<Prompt, string>();
var response = prompt.GetResponse();
```

This will retrieve an response object that has two properties: `State` and `Value`:
Expand All @@ -182,11 +183,11 @@ EmbeddedText text = new EmbeddedText(
"You just wrote " + response?.Value + "!",
"And you " + response?.Status + "!"
},
$"Next {Core.GetSelector.Item1}",
TextAlignment.Center
$"Next {Core.GetSelector.Item1}"
);

Window.AddElement(text);

Window.ActivateElement(text);
```

Expand Down Expand Up @@ -226,17 +227,17 @@ Window.AddElement(prompt);

Window.ActivateElement(prompt);

var response = Window.GetResponse<Prompt, string>();
var response = prompt.GetResponse();
EmbedText text = new EmbedText(
new List<string>()
{
"You just wrote " + response?.Value + "!",
"And you " + response?.Status + "!"
},
$"Next {Core.GetSelector.Item1}",
TextAlignment.Center
$"Next {Core.GetSelector.Item1}"
);
Window.AddElement(text);

Window.ActivateElement(text);

Window.Close();
Expand Down
2 changes: 1 addition & 1 deletion docs/introduction/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Window.Render();
Now at each refresh, the `Title` element will appear on screen. To disable it, you may add:

```csharp
Window.DeactivateElement<Title>();
Window.DeactivateElement(exampleTitle);
```

## Installation
Expand Down
Loading