Compare commits

...

44 Commits

Author SHA1 Message Date
lonix1
af9f5ea97d [docs] fixed typo (#956) 2022-09-09 13:33:06 +02:00
Cédric Luthi
e96a821ead Set the DevelopmentDependency flag on the Spectre.Console.Analyzer project
It was applied by mistake on Spectre.Console in #938.
2022-09-06 19:03:22 +02:00
lonix1
506253bc34 build: set nuget package as dev dependency
Docs: https://github.com/NuGet/Home/wiki/DevelopmentDependency-support-for-PackageReference
2022-08-29 10:20:32 +02:00
Bastian Eicher
90c2d988ab Detect non-interactive console via System.Console.IsInputRedirected instead of Environment.UserInteractive 2022-08-29 08:57:53 +02:00
Nils Andresen
2bd1383cbe Fixed punctuation 2022-08-29 08:54:30 +02:00
Nils Andresen
00a9ba325e restructured MarkupTokenizer a bit. 2022-08-29 08:54:30 +02:00
Nils Andresen
540bc1307c fixed warning 2022-08-29 08:54:30 +02:00
Nils Andresen
a6618f762c Modified MarkupTokenizer
So escaped markup in markup is valid.
2022-08-29 08:54:30 +02:00
Nils Andresen
638149f44b fixed punctuation in exception 2022-08-29 08:54:30 +02:00
Nils Andresen
0d72b94f9c added some breaking unit tests 2022-08-29 08:54:30 +02:00
Nils Andresen
0d19ccd8a6 (#916) fixed missing call to Validate when using CommandConstructorBinder 2022-08-18 12:03:11 +02:00
nkochnev
78d841e3dc Added command description to command help message (#920) 2022-08-17 16:59:08 +02:00
Nils Andresen
d94dc2fcb2 fixed build error
error NU1504: Duplicate 'PackageReference' items
found. Remove the duplicate items or use the Update
functionality to ensure a consistent restore behavior. The duplicate
'PackageReference' items are: System.Memory 4.5.5, System.Memory 4.5.5.
2022-08-17 16:03:44 +02:00
Nils Andresen
9d985f0f0a (#922) fixed ArgumentNullException on .NET Framework
It seems, when Spectre.Console is compiled for
netstandard2.0, StackTrace.GetFrames() returns null
instead of an empty array.
2022-08-17 16:03:44 +02:00
renovate[bot]
3a7b8aa1d2 chore: Update dependency xunit to v2.4.2 2022-08-03 15:04:26 +02:00
Patrik Svensson
dc93edef15 Remove the 'net50' TFM
Also updates all dependencies to the latest version.

Closes #829
2022-07-02 11:18:34 +02:00
renovate[bot]
b4cf7a76d3 chore: Update actions/upload-artifact action to v3 2022-07-01 12:45:58 +02:00
Patrik Svensson
45a051150f Fix for 'chore:' CI criteria 2022-07-01 12:42:24 +02:00
Patrik Svensson
47ef9a685e Do not run CI for commits starting with 'chore' 2022-07-01 12:36:48 +02:00
renovate[bot]
8ca602b986 chore: Update actions/setup-node action to v3 2022-07-01 12:08:53 +02:00
renovate[bot]
a11ae6a93d chore: Update actions/setup-dotnet action to v2 2022-07-01 12:08:37 +02:00
renovate[bot]
b13ff8ebcc chore: Update actions/checkout action to v3 2022-07-01 12:08:25 +02:00
renovate[bot]
90e6a1aa21 chore: Update actions/cache action to v3 2022-07-01 12:08:01 +02:00
Daniel Chalmers
f3a82073d9 Check for null argument in TextPrompt 2022-06-30 20:08:04 +02:00
dependabot[bot]
ff8fd9ed2a Bump Newtonsoft.Json from 12.0.3 to 13.0.1 in /examples/Console/Columns
Bumps [Newtonsoft.Json](https://github.com/JamesNK/Newtonsoft.Json) from 12.0.3 to 13.0.1.
- [Release notes](https://github.com/JamesNK/Newtonsoft.Json/releases)
- [Commits](https://github.com/JamesNK/Newtonsoft.Json/compare/12.0.3...13.0.1)

---
updated-dependencies:
- dependency-name: Newtonsoft.Json
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-30 14:32:43 +02:00
Patrik Svensson
1eeb32c704 Ignore the docs project 2022-06-30 14:24:03 +02:00
Cédric Luthi
c32decfa55 Fix the "Escaping Interpolated Strings" documentation
* `MarkupLineInterpolated` instead of `MarkupInterpolated`
* Use an actual interpolated string in sample code to make it valid
2022-06-30 13:55:52 +02:00
ivml
564c7b8f4e fix: API reference pages for Spectre.Console.Cli
This commit fixes #833.

`Spectre.Console.Cli` was moved into its own project, and the path to the new project was not added to the list of source files when building the documentation.
2022-05-17 17:46:50 +02:00
Patrik Svensson
5b2b4375a4 Update build script to package Spectre.Console.Cli 2022-05-15 00:09:52 +02:00
Patrik Svensson
70bbc24911 Update Cake to 2.2.0 2022-05-15 00:09:52 +02:00
Patrik Svensson
36ca22ffac Move Spectre.Console.Cli to it's own package 2022-05-15 00:09:52 +02:00
老大哥
b600832e00 add cross platform 2022-04-27 15:12:51 +02:00
Patrik Svensson
da1c471c18 Give GH Actions jobs a more suitable name 2022-04-15 10:44:14 +02:00
Patrik Svensson
b6b963c03c Update GPR dependency 2022-04-15 10:43:52 +02:00
Patrik Svensson
7e1fb43f21 Install .NET SDK 6.0.101 2022-04-15 10:28:49 +02:00
renovate[bot]
47fde1875b chore: Update dependency MinVer to v2.5.0 (#803)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2022-04-07 23:47:08 +02:00
renovate[bot]
eb85f5860e chore: Update dependency cake.tool to v2.1.0 (#809)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2022-04-07 23:46:15 +02:00
Nils Andresen
25a61bea91 Renovate: Ignore all updates to resources/scripts
those are used only during development, hence there
is no need to auto-update them.
2022-04-07 10:27:02 +02:00
renovate[bot]
bad6672d76 chore: Update dependency Microsoft.SourceLink.GitHub to v1.1.1 (#801)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2022-04-05 08:46:35 +02:00
Patrik Svensson
f614032c82 Fix documentation workflow (#799)
Only publish documentation when we publish artifacts.
2022-04-05 08:40:30 +02:00
Leonardo Costa
585f010b26 Upgrade dotnet example tool to 1.6.0 (#782) 2022-04-04 16:20:25 +02:00
renovate[bot]
90b917c38c Configure Renovate (#785)
* Add renovate.json

* Added a bit more configuration

also moved the config into .github subfolder so not to clutter
the root folder.

* ignore npm updates in docs

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Nils Andresen <nils@nils-andresen.de>
2022-04-03 22:16:48 +02:00
Drew Noakes
edbe9d6ebc Change section heading (#781)
This appears to have been copy/pasted from progress.md, which has a similar structure.
2022-03-31 14:18:24 +02:00
Patrik Svensson
90de1847d8 Add blog post for 0.44 2022-03-27 22:46:17 +02:00
307 changed files with 1290 additions and 327 deletions

20
.github/renovate.json vendored Normal file
View File

@@ -0,0 +1,20 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:base"
],
"dependencyDashboard": false,
"commitMessagePrefix": "chore:",
"labels": ["dependencies"],
"npm": {
"ignorePaths": [
"**/node_modules/**",
"**/bower_components/**",
"docs/**"
]
},
"ignorePaths": [
"resources/scripts/**",
"docs/**"
]
}

View File

@@ -1,3 +1,4 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Continuous Integration
on: pull_request
@@ -19,19 +20,15 @@ jobs:
uses: actions/checkout@master
- name: Setup .NET SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: |
5.0.301
6.0.100
uses: actions/setup-dotnet@v2
- name: Setup Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Cache dependencies
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.npm
key: npm-${{ hashFiles('package-lock.json') }}
@@ -47,7 +44,7 @@ jobs:
dotnet run --configuration Release
- name: Archive doc generation
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: documentation-output
path: docs/output/
@@ -73,17 +70,12 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup .NET SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: |
3.1.402
5.0.301
6.0.100
uses: actions/setup-dotnet@v2
- name: Integration Tests
shell: bash
@@ -99,7 +91,7 @@ jobs:
- name: Upload Verify Test Results
if: failure()
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: verify-test-results
path: |

View File

@@ -1,55 +0,0 @@
name: Deploy Documentation
on:
workflow_dispatch:
push:
paths:
- 'docs/**'
- 'src/**'
- 'test/**'
- 'examples/**'
- '.github/**'
jobs:
###################################################
# DOCS
###################################################
build:
name: Deploy
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup .NET SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: |
5.0.301
6.0.100
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '16'
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.npm
key: npm-${{ hashFiles('package-lock.json') }}
restore-keys: npm-
- name: Publish
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NETLIFY_ACCESS_TOKEN: ${{ secrets.NETLIFY_ACCESS_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
run: |
cd docs
dotnet tool restore
dotnet run --configuration Release -- deploy

View File

@@ -1,3 +1,4 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Publish
on:
@@ -13,41 +14,16 @@ env:
jobs:
###################################################
# DOCS
###################################################
docs:
name: Documentation
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master
- name: Setup .NET SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: |
5.0.301
6.0.100
- name: Build
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd docs
dotnet tool restore
dotnet run --configuration Release
###################################################
# BUILD
###################################################
build:
name: Build
needs: [docs]
if: "!contains(github.event.head_commit.message, 'skip-ci') || startsWith(github.ref, 'refs/tags/')"
if: |
(!startsWith(github.event.head_commit.message, 'skip-ci')
&& !startsWith(github.event.head_commit.message, 'chore:'))
|| startsWith(github.ref, 'refs/tags/')
strategy:
matrix:
kind: ['linux', 'windows', 'macOS']
@@ -61,17 +37,12 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup .NET SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: |
3.1.402
5.0.301
6.0.100
uses: actions/setup-dotnet@v2
- name: Build
shell: bash
@@ -79,28 +50,63 @@ jobs:
dotnet tool restore
dotnet cake
###################################################
# DOCS
###################################################
documentation:
name: Publish Documentation
needs: [build]
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup .NET SDK
uses: actions/setup-dotnet@v2
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: npm-${{ hashFiles('package-lock.json') }}
restore-keys: npm-
- name: Publish Documentation
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NETLIFY_ACCESS_TOKEN: ${{ secrets.NETLIFY_ACCESS_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
run: |
cd docs
dotnet tool restore
dotnet run --configuration Release -- deploy
###################################################
# PUBLISH
###################################################
publish:
name: Publish
name: Publish NuGet Packages
needs: [build]
if: "!contains(github.event.head_commit.message, 'skip-ci') || startsWith(github.ref, 'refs/tags/')"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup .NET SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: |
3.1.402
5.0.301
6.0.100
uses: actions/setup-dotnet@v2
- name: Publish
shell: bash

View File

@@ -2,7 +2,7 @@
_[![Spectre.Console NuGet Version](https://img.shields.io/nuget/v/spectre.console.svg?style=flat&label=NuGet%3A%20Spectre.Console)](https://www.nuget.org/packages/spectre.console)_
`Spectre.Console`是一个 .NET 5/.NET Standard 2.0 的库,能让您在终端里更方便地生成精美的界面
`Spectre.Console`是一个 .NET 5/.NET Standard 2.0 的库,可以更轻松地创建美观的跨平台控制台应用程序
深受 [Rich](https://github.com/willmcgugan/rich) 这个Python优秀库的启发。
@@ -26,7 +26,7 @@ _[![Spectre.Console NuGet Version](https://img.shields.io/nuget/v/spectre.consol
## 安装
最快的安装方式就是用NuGet包管理直接安装Spectre.Console。
最快的安装方式就是用NuGet包管理直接安装`Spectre.Console`
```csharp
dotnet add package Spectre.Console

View File

@@ -58,6 +58,12 @@ Task("Test")
NoBuild = true,
});
DotNetTest("./test/Spectre.Console.Cli.Tests/Spectre.Console.Cli.Tests.csproj", new DotNetTestSettings {
Configuration = configuration,
NoRestore = true,
NoBuild = true,
});
DotNetTest("./test/Spectre.Console.Analyzer.Tests/Spectre.Console.Analyzer.Tests.csproj", new DotNetTestSettings {
Configuration = configuration,
NoRestore = true,

View File

@@ -38,7 +38,7 @@
<PackageReference Include="Statiq.CodeAnalysis" Version="1.0.0-beta.58" />
<PackageReference Include="Statiq.Common" Version="1.0.0-beta.58" />
<PackageReference Include="Statiq.Web" Version="1.0.0-beta.44" />
<PackageReference Include="MinVer" PrivateAssets="All" Version="2.3.1" />
<PackageReference Include="MinVer" PrivateAssets="All" Version="2.5.0" />
<PackageReference Include="Statiq.Web.Netlify" Version="1.0.0-beta.44" />
</ItemGroup>

View File

@@ -22,6 +22,7 @@ namespace Docs
.AddSetting(Constants.SourceFiles, new List<string>
{
"../../src/Spectre.Console/**/{!bin,!obj,!packages,!*.Tests,}/**/*.cs",
"../../src/Spectre.Console.Cli/**/{!bin,!obj,!packages,!*.Tests,}/**/*.cs",
"../../src/Spectre.Console.ImageSharp/**/{!bin,!obj,!packages,!*.Tests,}/**/*.cs"
})
.AddSetting(Constants.ExampleSourceFiles, new List<string>

View File

@@ -1,6 +1,6 @@
{
"sdk": {
"version": "2.2.200",
"rollForward": "latestMajor"
"version": "6.0.300",
"rollForward": "latestFeature"
}
}
}

View File

@@ -0,0 +1,63 @@
Title: Spectre.Console 0.44 released!
Description: Alternate screen buffers, better exception rendering... and more!
Published: 20220327
Category: Release Notes
Excluded: false
---
Version 0.44 of Spectre.Console has been released!
There are a lot of fixes and improvements in this release, but the most noteworthy
additions are better exception rendering, support for alternate screen buffers,
and a new widget called [TextPath](xref:T:Spectre.Console.TextPath), which makes
it easy to render paths in the console.
Check out the two new examples in our GitHub repository:
* [./examples/Console/AlternateScreen](https://github.com/spectreconsole/spectre.console/blob/main/examples/Console/AlternateScreen/Program.cs)
* [./examples/Console/Paths](https://github.com/spectreconsole/spectre.console/blob/main/examples/Console/Paths/Program.cs)
## New Contributors
* [@twaalewijn](https://github.com/twaalewijn) made their first contribution in [#642](https://github.com/spectreconsole/spectre.console/pull/642)
* [@zmrfzn](https://github.com/zmrfzn) made their first contribution in [#652](https://github.com/spectreconsole/spectre.console/pull/652)
* [@jouniheikniemi](https://github.com/jouniheikniemi) made their first contribution in [#689](https://github.com/spectreconsole/spectre.console/pull/689)
* [@Sir-Baconn](https://github.com/Sir-Baconn) made their first contribution in [#682](https://github.com/spectreconsole/spectre.console/pull/682)
* [@seclerp](https://github.com/seclerp) made their first contribution in [#665](https://github.com/spectreconsole/spectre.console/pull/665)
* [@Arcodiant](https://github.com/Arcodiant) made their first contribution in [#748](https://github.com/spectreconsole/spectre.console/pull/748)
* [@ap0llo](https://github.com/ap0llo) made their first contribution in [#681](https://github.com/spectreconsole/spectre.console/pull/681)
## What's Changed
* Added the ability to hide CommandOptions. by [@twaalewijn](https://github.com/twaalewijn) in [#642](https://github.com/spectreconsole/spectre.console/pull/642)
* Add support for alternate screen buffers by [@patriksvensson](https://github.com/patriksvensson) in [#647](https://github.com/spectreconsole/spectre.console/pull/647)
* Updates asciinema update by [@phil-scott-78](https://github.com/phil-scott-78) in [#648](https://github.com/spectreconsole/spectre.console/pull/648)
* Update Roslynator.Analyzers to version 3.3 by [@phil-scott-78](https://github.com/phil-scott-78) in [#650](https://github.com/spectreconsole/spectre.console/pull/650)
* Ordered CommandArguments by position by [@nils-a](https://github.com/nils-a) in [#646](https://github.com/spectreconsole/spectre.console/pull/646)
* Table title's first letter is getting capitalized by default by [@zmrfzn](https://github.com/zmrfzn) in [#652](https://github.com/spectreconsole/spectre.console/pull/652)
* Simplify stack frame parsing by [@0xced](https://github.com/0xced) in [#637](https://github.com/spectreconsole/spectre.console/pull/637)
* Trying to rework dotnet tools for docs and playwright by [@phil-scott-78](https://github.com/phil-scott-78) in [#667](https://github.com/spectreconsole/spectre.console/pull/667)
* Add release notes for 0.43.0 by [@patriksvensson](https://github.com/patriksvensson) in [#663](https://github.com/spectreconsole/spectre.console/pull/663)
* Use file scoped namespace declarations by [@patriksvensson](https://github.com/patriksvensson) in [#666](https://github.com/spectreconsole/spectre.console/pull/666)
* Add global usings by [@patriksvensson](https://github.com/patriksvensson) in [#668](https://github.com/spectreconsole/spectre.console/pull/668)
* Changed TypeResolver in Cli/logging by [@nils-a](https://github.com/nils-a) in [#675](https://github.com/spectreconsole/spectre.console/pull/675)
* Invalid WithExample call on the CommandApp doc page by [@jouniheikniemi](https://github.com/jouniheikniemi) in [#689](https://github.com/spectreconsole/spectre.console/pull/689)
* Add overload with params array for AddChoiceGroup() by [@Sir-Baconn](https://github.com/Sir-Baconn) in [#682](https://github.com/spectreconsole/spectre.console/pull/682)
* Simplify exception formatting by [@0xced](https://github.com/0xced) in [#695](https://github.com/spectreconsole/spectre.console/pull/695)
* Improves exception rendering for async methods in .NET 6 by [@phil-scott-78](https://github.com/phil-scott-78) in [#718](https://github.com/spectreconsole/spectre.console/pull/718)
* Adding better type names for return types and parameters by [@phil-scott-78](https://github.com/phil-scott-78) in [#719](https://github.com/spectreconsole/spectre.console/pull/719)
* Docs redesign by [@phil-scott-78](https://github.com/phil-scott-78) in [#728](https://github.com/spectreconsole/spectre.console/pull/728)
* Configures deployment to netlify by [@phil-scott-78](https://github.com/phil-scott-78) in [#729](https://github.com/spectreconsole/spectre.console/pull/729)
* Tweaking font-size and line-height for smaller screens by [@phil-scott-78](https://github.com/phil-scott-78) in [#730](https://github.com/spectreconsole/spectre.console/pull/730)
* Adding a best practices guide. by [@phil-scott-78](https://github.com/phil-scott-78) in [#744](https://github.com/spectreconsole/spectre.console/pull/744)
* Adds widget for displaying (pretty) paths by [@patriksvensson](https://github.com/patriksvensson) in [#734](https://github.com/spectreconsole/spectre.console/pull/734)
* Add missing inheritance and nullable types in settings.md by [@seclerp](https://github.com/seclerp) in [#665](https://github.com/spectreconsole/spectre.console/pull/665)
* Optimizing build by [@phil-scott-78](https://github.com/phil-scott-78) in [#747](https://github.com/spectreconsole/spectre.console/pull/747)
* Update SixLabors.ImageSharp reference by [@Arcodiant](https://github.com/Arcodiant) in [#748](https://github.com/spectreconsole/spectre.console/pull/748)
* Add support for styling and aligning paths by [@patriksvensson](https://github.com/patriksvensson) in [#746](https://github.com/spectreconsole/spectre.console/pull/746)
* Add documentation for `TextPath` widget by [@patriksvensson](https://github.com/patriksvensson) in [#757](https://github.com/spectreconsole/spectre.console/pull/757)
* Fix path and description for TextPath docs by [@patriksvensson](https://github.com/patriksvensson) in [#758](https://github.com/spectreconsole/spectre.console/pull/758)
* Adding a short template file for new documentation by [@phil-scott-78](https://github.com/phil-scott-78) in [#763](https://github.com/spectreconsole/spectre.console/pull/763)
* Introduce MarkupInterpolated and MarkupLineInterpolated extensions by [@phil-scott-78](https://github.com/phil-scott-78) in [#761](https://github.com/spectreconsole/spectre.console/pull/761)
* Obsolete the AnsiConsoleFactory class by [@0xced](https://github.com/0xced) in [#585](https://github.com/spectreconsole/spectre.console/pull/585)
* Add option to configure the style of the choices list and the default value in TextPrompt by [@ap0llo](https://github.com/ap0llo) in [#681](https://github.com/spectreconsole/spectre.console/pull/681)

View File

@@ -46,7 +46,7 @@ AnsiConsole.Status()
});
```
## Asynchronous progress
## Asynchronous status
If you prefer to use async/await, you can use `StartAsync` instead of `Start`.

View File

@@ -66,10 +66,11 @@ AnsiConsole.Markup("[red]{0}[/]", Markup.Escape("Hello [World]"));
## Escaping Interpolated Strings
When working with interpolated string, you can use the `MarkupInterpolated` and `MarkupInterpolatedLine` methods to automatically escape the values in the interpolated string holes.
When working with interpolated string, you can use the `MarkupInterpolated` and `MarkupLineInterpolated` methods to automatically escape the values in the interpolated string holes.
```csharp
AnsiConsole.MarkupInterpolated("[red]{0}[/]", "Hello [World]");
string hello = "Hello [World]";
AnsiConsole.MarkupInterpolated($"[red]{hello}[/]");
```
## Setting background color

View File

@@ -43,7 +43,7 @@ AnsiConsole.Write(root);
## Collapsing nodes
```csharp
root.AddNode("Label").Collapsed();
root.AddNode("Label").Collapse();
```
## Appearance

View File

@@ -3,19 +3,19 @@
"isRoot": true,
"tools": {
"cake.tool": {
"version": "2.0.0-rc0001",
"version": "2.2.0",
"commands": [
"dotnet-cake"
]
},
"gpr": {
"version": "0.1.224",
"version": "0.1.281",
"commands": [
"gpr"
]
},
"dotnet-example": {
"version": "1.5.0",
"version": "1.6.0",
"commands": [
"dotnet-example"
]

View File

@@ -11,7 +11,7 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\src\Spectre.Console\Spectre.Console.csproj" />
<ProjectReference Include="..\..\..\src\Spectre.Console.Cli\Spectre.Console.Cli.csproj" />
</ItemGroup>
</Project>

View File

@@ -11,7 +11,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.8" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
</ItemGroup>
<ItemGroup>

View File

@@ -12,10 +12,10 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.1" />
<PackageReference Include="Serilog" Version="2.10.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="3.0.1" />
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
<PackageReference Include="Serilog" Version="2.11.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="3.1.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="Serilog.Sinks.Map" Version="1.0.2" />
</ItemGroup>

View File

@@ -9,7 +9,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
<ItemGroup>

View File

@@ -9,7 +9,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
<ItemGroup>

View File

@@ -9,7 +9,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
<ItemGroup>

View File

@@ -75,6 +75,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Spectre.Console.ImageSharp"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Paths", "Console\Paths\Paths.csproj", "{65CB00B0-A3AE-4E8F-A990-4C8C1A232FE2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Spectre.Console.Cli", "..\src\Spectre.Console.Cli\Spectre.Console.Cli.csproj", "{EFAADF6A-C77D-41EC-83F5-BBB4FFC5A6D7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -493,6 +495,18 @@ Global
{65CB00B0-A3AE-4E8F-A990-4C8C1A232FE2}.Release|x64.Build.0 = Release|Any CPU
{65CB00B0-A3AE-4E8F-A990-4C8C1A232FE2}.Release|x86.ActiveCfg = Release|Any CPU
{65CB00B0-A3AE-4E8F-A990-4C8C1A232FE2}.Release|x86.Build.0 = Release|Any CPU
{EFAADF6A-C77D-41EC-83F5-BBB4FFC5A6D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EFAADF6A-C77D-41EC-83F5-BBB4FFC5A6D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EFAADF6A-C77D-41EC-83F5-BBB4FFC5A6D7}.Debug|x64.ActiveCfg = Debug|Any CPU
{EFAADF6A-C77D-41EC-83F5-BBB4FFC5A6D7}.Debug|x64.Build.0 = Debug|Any CPU
{EFAADF6A-C77D-41EC-83F5-BBB4FFC5A6D7}.Debug|x86.ActiveCfg = Debug|Any CPU
{EFAADF6A-C77D-41EC-83F5-BBB4FFC5A6D7}.Debug|x86.Build.0 = Debug|Any CPU
{EFAADF6A-C77D-41EC-83F5-BBB4FFC5A6D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EFAADF6A-C77D-41EC-83F5-BBB4FFC5A6D7}.Release|Any CPU.Build.0 = Release|Any CPU
{EFAADF6A-C77D-41EC-83F5-BBB4FFC5A6D7}.Release|x64.ActiveCfg = Release|Any CPU
{EFAADF6A-C77D-41EC-83F5-BBB4FFC5A6D7}.Release|x64.Build.0 = Release|Any CPU
{EFAADF6A-C77D-41EC-83F5-BBB4FFC5A6D7}.Release|x86.ActiveCfg = Release|Any CPU
{EFAADF6A-C77D-41EC-83F5-BBB4FFC5A6D7}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -506,6 +520,7 @@ Global
{DD8EC1B0-F50C-44E4-8399-2D560F95E572} = {2571F1BD-6556-4F96-B27B-B6190E1BF13A}
{0C58FB17-F60A-47AB-84BF-961EC8C06AE6} = {2571F1BD-6556-4F96-B27B-B6190E1BF13A}
{A127CE7D-A5A7-4745-9809-EBD7CB12CEE7} = {2571F1BD-6556-4F96-B27B-B6190E1BF13A}
{EFAADF6A-C77D-41EC-83F5-BBB4FFC5A6D7} = {2571F1BD-6556-4F96-B27B-B6190E1BF13A}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3EE724C5-CAB4-410D-AC63-8D4260EF83ED}

View File

@@ -7,6 +7,7 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Spectre.Console.Cli\Spectre.Console.Cli.csproj" />
<ProjectReference Include="..\..\src\Spectre.Console\Spectre.Console.csproj" />
</ItemGroup>

View File

@@ -1,7 +1,7 @@
{
"projects": [ "src", "tests" ],
"sdk": {
"version": "6.0.100",
"version": "6.0.300",
"rollForward": "latestFeature"
}
}

View File

@@ -32,12 +32,12 @@
</PropertyGroup>
<ItemGroup Label="Package References">
<PackageReference Include="MinVer" PrivateAssets="All" Version="2.4.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="All" Version="1.0.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.312">
<PackageReference Include="MinVer" PrivateAssets="All" Version="4.1.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="All" Version="1.1.1" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.435">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="Roslynator.Analyzers" Version="3.3.0">
<PackageReference Include="Roslynator.Analyzers" Version="4.1.1">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
</ItemGroup>

View File

@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<AdditionalFiles Include="..\stylecop.json" Link="Properties/stylecop.json" />

View File

@@ -0,0 +1,6 @@
<SolutionConfiguration>
<Settings>
<AllowParallelTestExecution>True</AllowParallelTestExecution>
<SolutionConfigured>True</SolutionConfigured>
</Settings>
</SolutionConfiguration>

View File

@@ -24,7 +24,7 @@ public class FavorInstanceAnsiConsoleOverStaticAnalyzer : SpectreAnalyzer
// if this operation isn't an invocation against one of the System.Console methods
// defined in _methods then we can safely stop analyzing and return;
var invocationOperation = (IInvocationOperation)context.Operation;
if (!Equals(invocationOperation.TargetMethod.ContainingType, ansiConsoleType))
if (!SymbolEqualityComparer.Default.Equals(invocationOperation.TargetMethod.ContainingType, ansiConsoleType))
{
return;
}
@@ -63,7 +63,7 @@ public class FavorInstanceAnsiConsoleOverStaticAnalyzer : SpectreAnalyzer
.Ancestors().OfType<MethodDeclarationSyntax>()
.First()
.ParameterList.Parameters
.Any(i => i.Type.NormalizeWhitespace().ToString() == "IAnsiConsole");
.Any(i => i.Type?.NormalizeWhitespace()?.ToString() == "IAnsiConsole");
}
private static bool HasFieldAnsiConsole(SyntaxNode syntaxNode)
@@ -72,7 +72,7 @@ public class FavorInstanceAnsiConsoleOverStaticAnalyzer : SpectreAnalyzer
.Ancestors()
.OfType<MethodDeclarationSyntax>()
.First()
.Modifiers.Any(i => i.Kind() == SyntaxKind.StaticKeyword);
.Modifiers.Any(i => i.IsKind(SyntaxKind.StaticKeyword));
return syntaxNode
.Ancestors().OfType<ClassDeclarationSyntax>()
@@ -81,6 +81,6 @@ public class FavorInstanceAnsiConsoleOverStaticAnalyzer : SpectreAnalyzer
.OfType<FieldDeclarationSyntax>()
.Any(i =>
i.Declaration.Type.NormalizeWhitespace().ToString() == "IAnsiConsole" &&
(!isStatic ^ i.Modifiers.Any(modifier => modifier.Kind() == SyntaxKind.StaticKeyword)));
(!isStatic ^ i.Modifiers.Any(modifier => modifier.IsKind(SyntaxKind.StaticKeyword))));
}
}

View File

@@ -33,12 +33,14 @@ public class NoConcurrentLiveRenderablesAnalyzer : SpectreAnalyzer
.Select(i => context.Compilation.GetTypeByMetadataName(i))
.ToImmutableArray();
if (liveTypes.All(i => !Equals(i, methodSymbol.ContainingType)))
if (liveTypes.All(i => !SymbolEqualityComparer.Default.Equals(i, methodSymbol.ContainingType)))
{
return;
}
#pragma warning disable RS1030 // Do not invoke Compilation.GetSemanticModel() method within a diagnostic analyzer
var model = context.Compilation.GetSemanticModel(context.Operation.Syntax.SyntaxTree);
#pragma warning restore RS1030 // Do not invoke Compilation.GetSemanticModel() method within a diagnostic analyzer
var parentInvocations = invocationOperation
.Syntax.Ancestors()
.OfType<InvocationExpressionSyntax>()

View File

@@ -34,12 +34,15 @@ public class NoPromptsDuringLiveRenderablesAnalyzer : SpectreAnalyzer
var ansiConsoleType = context.Compilation.GetTypeByMetadataName("Spectre.Console.AnsiConsole");
var ansiConsoleExtensionsType = context.Compilation.GetTypeByMetadataName("Spectre.Console.AnsiConsoleExtensions");
if (!Equals(methodSymbol.ContainingType, ansiConsoleType) && !Equals(methodSymbol.ContainingType, ansiConsoleExtensionsType))
if (!SymbolEqualityComparer.Default.Equals(methodSymbol.ContainingType, ansiConsoleType) &&
!SymbolEqualityComparer.Default.Equals(methodSymbol.ContainingType, ansiConsoleExtensionsType))
{
return;
}
#pragma warning disable RS1030 // Do not invoke Compilation.GetSemanticModel() method within a diagnostic analyzer
var model = context.Compilation.GetSemanticModel(context.Operation.Syntax.SyntaxTree);
#pragma warning restore RS1030 // Do not invoke Compilation.GetSemanticModel() method within a diagnostic analyzer
var parentInvocations = invocationOperation
.Syntax.Ancestors()
.OfType<InvocationExpressionSyntax>()

View File

@@ -33,7 +33,7 @@ public class UseSpectreInsteadOfSystemConsoleAnalyzer : SpectreAnalyzer
var systemConsoleType = context.Compilation.GetTypeByMetadataName("System.Console");
if (!Equals(invocationOperation.TargetMethod.ContainingType, systemConsoleType))
if (!SymbolEqualityComparer.Default.Equals(invocationOperation.TargetMethod.ContainingType, systemConsoleType))
{
return;
}

View File

@@ -35,6 +35,11 @@ public class SwitchToAnsiConsoleAction : CodeAction
var originalCaller = ((MemberAccessExpressionSyntax)_originalInvocation.Expression).Name.ToString();
var syntaxTree = await _document.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false);
if (syntaxTree == null)
{
return _document;
}
var root = (CompilationUnitSyntax)await syntaxTree.GetRootAsync(cancellationToken).ConfigureAwait(false);
// If there is an ansiConsole passed into the method then we'll use it.
@@ -66,7 +71,7 @@ public class SwitchToAnsiConsoleAction : CodeAction
.Ancestors().OfType<MethodDeclarationSyntax>()
.First()
.ParameterList.Parameters
.FirstOrDefault(i => i.Type.NormalizeWhitespace().ToString() == "IAnsiConsole")
.FirstOrDefault(i => i.Type?.NormalizeWhitespace()?.ToString() == "IAnsiConsole")
?.Identifier.Text;
}
@@ -79,7 +84,7 @@ public class SwitchToAnsiConsoleAction : CodeAction
.Ancestors()
.OfType<MethodDeclarationSyntax>()
.First()
.Modifiers.Any(i => i.Kind() == SyntaxKind.StaticKeyword);
.Modifiers.Any(i => i.IsKind(SyntaxKind.StaticKeyword));
return _originalInvocation
.Ancestors().OfType<ClassDeclarationSyntax>()
@@ -88,7 +93,7 @@ public class SwitchToAnsiConsoleAction : CodeAction
.OfType<FieldDeclarationSyntax>()
.FirstOrDefault(i =>
i.Declaration.Type.NormalizeWhitespace().ToString() == "IAnsiConsole" &&
(!isStatic ^ i.Modifiers.Any(modifier => modifier.Kind() == SyntaxKind.StaticKeyword)))
(!isStatic ^ i.Modifiers.Any(modifier => modifier.IsKind(SyntaxKind.StaticKeyword))))
?.Declaration.Variables.First().Identifier.Text;
}

View File

@@ -18,9 +18,18 @@ public class StaticAnsiConsoleToInstanceFix : CodeFixProvider
public override async Task RegisterCodeFixesAsync(CodeFixContext context)
{
var root = await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false);
var methodDeclaration = root.FindNode(context.Span).FirstAncestorOrSelf<InvocationExpressionSyntax>();
context.RegisterCodeFix(
new SwitchToAnsiConsoleAction(context.Document, methodDeclaration, "Convert static AnsiConsole calls to local instance."),
context.Diagnostics);
if (root != null)
{
var methodDeclaration = root.FindNode(context.Span).FirstAncestorOrSelf<InvocationExpressionSyntax>();
if (methodDeclaration != null)
{
context.RegisterCodeFix(
new SwitchToAnsiConsoleAction(
context.Document,
methodDeclaration,
"Convert static AnsiConsole calls to local instance."),
context.Diagnostics);
}
}
}
}

View File

@@ -18,9 +18,18 @@ public class SystemConsoleToAnsiConsoleFix : CodeFixProvider
public override async Task RegisterCodeFixesAsync(CodeFixContext context)
{
var root = await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false);
var methodDeclaration = root.FindNode(context.Span).FirstAncestorOrSelf<InvocationExpressionSyntax>();
context.RegisterCodeFix(
new SwitchToAnsiConsoleAction(context.Document, methodDeclaration, "Convert static call to AnsiConsole to Spectre.Console.AnsiConsole"),
context.Diagnostics);
if (root != null)
{
var methodDeclaration = root.FindNode(context.Span).FirstAncestorOrSelf<InvocationExpressionSyntax>();
if (methodDeclaration != null)
{
context.RegisterCodeFix(
new SwitchToAnsiConsoleAction(
context.Document,
methodDeclaration,
"Convert static call to AnsiConsole to Spectre.Console.AnsiConsole"),
context.Diagnostics);
}
}
}
}

View File

@@ -1,9 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>Best practice analyzers for Spectre.Console.</Description>
<TargetFramework>netstandard2.0</TargetFramework>
<IsPackable>true</IsPackable>
<DevelopmentDependency>true</DevelopmentDependency>
<IncludeBuildOutput>false</IncludeBuildOutput>
<Nullable>enable</Nullable>
<NoPackageAnalysis>true</NoPackageAnalysis>
@@ -15,9 +16,10 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="2.9.8" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="2.6.1" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="2.6.1" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.3" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis" Version="4.2.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.2.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.2.0" PrivateAssets="all" />
</ItemGroup>
<ItemGroup>

View File

@@ -45,6 +45,13 @@ internal static class CommandConstructorBinder
}
}
// Validate the settings.
var validationResult = settings.Validate();
if (!validationResult.Successful)
{
throw CommandRuntimeException.ValidationFailed(validationResult);
}
return settings;
}
}

Some files were not shown because too many files have changed in this diff Show More