File tree Expand file tree Collapse file tree 10 files changed +147
-7
lines changed Expand file tree Collapse file tree 10 files changed +147
-7
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ name : Bug report / 错误报告
3
+ about : Create a report to help us improve / 创建报告以帮助我们改进
4
+ title : " [bug] "
5
+ labels : bug
6
+ ---
7
+
8
+ <!--
9
+ 请提供下述完整信息以便快速定位问题 / Please provide the following information to quickly locate the problem
10
+ -->
11
+
12
+ - 系统环境 / System Environment:
13
+
14
+
15
+ - 版本号 / Version:
16
+
17
+
18
+ - 问题描述 / Description of the issue:
19
+
20
+
21
+ - 复现步骤 / Reproduction steps:
22
+
Original file line number Diff line number Diff line change
1
+ ---
2
+ name : Feel free to express / 随便写写
3
+ about : Record something / 简单写写记录记录
4
+ ---
5
+
6
+ - Feel free to express yourself / 请自由发挥
7
+
Original file line number Diff line number Diff line change
1
+ ---
2
+ name : I have a question / 我有疑问
3
+ about : Solve your problem / 解决你的疑问
4
+ title : " [question] "
5
+ labels : question
6
+ ---
7
+
8
+ - Problem Description / 问题描述
9
+
Original file line number Diff line number Diff line change
1
+ ---
2
+ name : I have suggestions / 我有建议
3
+ about : Your suggestions may benefit everyone / 你的建议可能让所有人受益
4
+ title : " [suggestion] "
5
+ labels : suggestion
6
+ ---
7
+
8
+ - Your suggestions / 你的建议
9
+
Original file line number Diff line number Diff line change
1
+ name : pack
2
+
3
+ on :
4
+ release :
5
+ types : [created]
6
+ push :
7
+ branches :
8
+ - master
9
+
10
+ jobs :
11
+ build :
12
+ runs-on : windows-latest
13
+
14
+ steps :
15
+ - uses : actions/checkout@v3
16
+
17
+ - name : Setup .NET
18
+ uses : actions/setup-dotnet@v2
19
+ with :
20
+ dotnet-version : 8.0.x
21
+
22
+ - name : Setup Windows SDK
23
+ uses :
GuillaumeFalourd/[email protected]
24
+
25
+ - name : Install dependencies
26
+ run : dotnet restore
27
+
28
+ - name : Build
29
+ run : dotnet build --configuration Release --no-restore
30
+
31
+ - name : Pack
32
+ run : dotnet pack src\Flucli\Flucli.csproj -c Release --no-build -o out
33
+
34
+ - name : Push NuGet package
35
+ # run: dotnet nuget push "out\*.nupkg" -k ${{secrets.NUGET_AUTH_TOKEN}} --source https://api.nuget.org/v3/index.json
36
+ uses : actions/upload-artifact@v3
37
+ with :
38
+ name : nuget-packages
39
+ path : out/*.nupkg
Original file line number Diff line number Diff line change
1
+ [ ![ NuGet] ( https://img.shields.io/nuget/v/Flucli.svg )] ( https://nuget.org/packages/Flucli ) [ ![ GitHub license] ( https://img.shields.io/github/license/lemutec/Flucli )] ( https://github.com/lemutec/Flucli/blob/master/LICENSE.txt ) [ ![ Actions] ( https://github.com/lemutec/Flucli/actions/workflows/library.nuget.yml/badge.svg )] ( https://github.com/lemutec/Flucli/actions/workflows/library.nuget.yml )
2
+
1
3
# Flucli
4
+
5
+ Library for interacting with external command-line interfaces.
6
+
7
+ Ported from [ CliWrap] ( https://github.com/Tyrrrz/CliWrap ) and support ` .netstandard 2.0 ` without other dependencies.
8
+
9
+ Support ` Verb="runas" ` and simplify some APIs.
10
+
11
+ ## Usage
12
+
13
+ ``` c#
14
+ StringBuilder stdout = new ();
15
+ StringBuilder stderr = new ();
16
+
17
+ var command1 = " cmd"
18
+ .WithArguments (" /c echo Hello World!" );
19
+
20
+ var command2 = " cmd"
21
+ .WithArguments (" /c findstr o" )
22
+ .WithStandardOutputPipe (PipeTarget .ToStringBuilder (stdout , Encoding .UTF8 ))
23
+ .WithStandardErrorPipe (PipeTarget .ToStringBuilder (stderr , Encoding .UTF8 ));
24
+
25
+ CliResult result = await (command1 | command2 ).ExecuteAsync ();
26
+
27
+ Console .WriteLine (" STDOUT: " + stdout .ToString ());
28
+ Console .WriteLine (" STDERR: " + stderr .ToString ());
29
+ Console .WriteLine (" ExitCode is " + result .ExitCode );
30
+ ```
31
+
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change @@ -8,20 +8,21 @@ static void Main(string[] args)
8
8
{
9
9
Task . Run ( async ( ) =>
10
10
{
11
- byte [ ] array = new byte [ 100 ] ;
12
- using MemoryStream ms = new ( array ) ;
11
+ StringBuilder stdout = new ( ) ;
12
+ StringBuilder stderr = new ( ) ;
13
13
14
14
var command1 = "cmd"
15
- . WithArguments ( "/c echo Hello" ) ;
15
+ . WithArguments ( "/c echo Hello World! " ) ;
16
16
17
17
var command2 = "cmd"
18
- . WithArguments ( "/c findstr H" )
19
- . WithStandardOutputPipe ( PipeTarget . ToStream ( ms ) ) ;
18
+ . WithArguments ( "/c findstr o" )
19
+ . WithStandardOutputPipe ( PipeTarget . ToStringBuilder ( stdout , Encoding . UTF8 ) )
20
+ . WithStandardErrorPipe ( PipeTarget . ToStringBuilder ( stderr , Encoding . UTF8 ) ) ;
20
21
21
22
CliResult result = await ( command1 | command2 ) . ExecuteAsync ( ) ;
22
- string output = Encoding . UTF8 . GetString ( array ) ;
23
23
24
- Console . WriteLine ( "STDOUT: " + output ) ;
24
+ Console . WriteLine ( "STDOUT: " + stdout . ToString ( ) ) ;
25
+ Console . WriteLine ( "STDERR: " + stderr . ToString ( ) ) ;
25
26
Console . WriteLine ( "ExitCode is " + result . ExitCode ) ;
26
27
} ) ;
27
28
Original file line number Diff line number Diff line change 1
1
<Project Sdk =" Microsoft.NET.Sdk" >
2
2
3
3
<PropertyGroup >
4
+ <PackageId >Flucli</PackageId >
5
+ <Product >Flucli</Product >
4
6
<TargetFrameworks >.netstandard2.0;net471;net472;net48;net481;net5.0-windows;net6.0-windows;net7.0-windows;net8.0-windows;</TargetFrameworks >
5
7
<Nullable >enable</Nullable >
6
8
<LangVersion >latest</LangVersion >
9
+ <AssemblyName >Flucli</AssemblyName >
10
+ <EnableWindowsTargeting >true</EnableWindowsTargeting >
11
+ <GeneratePackageOnBuild >true</GeneratePackageOnBuild >
12
+ <AssemblyVersion >0.1.0.0</AssemblyVersion >
13
+ <FileVersion >0.1.0.0</FileVersion >
14
+ <Version >$(VersionPrefix)0.1.0.0-beta</Version >
15
+ <Authors >ema</Authors >
16
+ <Company >Lemutec</Company >
17
+ <Description >Library for interacting with external command-line interfaces</Description >
18
+ <PackageProjectUrl >https://github.com/lemutec/Flucli</PackageProjectUrl >
19
+ <RepositoryUrl >https://github.com/lemutec/Flucli</RepositoryUrl >
20
+ <RepositoryType >git</RepositoryType >
21
+ <PackageTags >.NET CLI PROCESS</PackageTags >
22
+ <PackageLicenseExpression >MIT</PackageLicenseExpression >
23
+ <PackageReadmeFile >README.md</PackageReadmeFile >
24
+ <PackageIcon >logo.png</PackageIcon >
7
25
</PropertyGroup >
8
26
27
+ <ItemGroup >
28
+ <None Include =" ..\..\README.md" Pack =" true" PackagePath =" " />
29
+ <None Include =" ..\..\image\logo.png" Pack =" true" PackagePath =" " />
30
+ </ItemGroup >
31
+
9
32
</Project >
You can’t perform that action at this time.
0 commit comments