Skip to content

Commit 0af0c3c

Browse files
committed
Add docfx site content
1 parent 4c2502a commit 0af0c3c

File tree

6 files changed

+223
-0
lines changed

6 files changed

+223
-0
lines changed

Directory.Build.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
2525
<GenerateFullPaths Condition="'$(VSCODE_PID)' != ''">true</GenerateFullPaths>
26+
<BaseIntermediateOutputPath>$(MSBuildThisFileDirectory)obj\$(MSBuildProjectName)\</BaseIntermediateOutputPath>
27+
<BaseOutputPath>$(MSBuildThisFileDirectory)bin\$(MSBuildProjectName)\</BaseOutputPath>
2628
</PropertyGroup>
2729

2830
</Project>

docfx_project/api/index.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
API Reference
2+
=============
3+
4+
McMaster.Extensions.CommandLineUtils supports three target frameworks.
5+
6+
- .NET Standard 2.0
7+
- .NET Standard 1.6
8+
- .NET Framework 4.5
9+
10+
The API is almost identical between all of the frameworks.
11+
12+
The main entry point for most command line applications is [CommandLineApplication](xref:McMaster.Extensions.CommandLineUtils.CommandLineApplication).
13+
14+
For apps built using attributes, these are the most common attributes used:
15+
16+
- [OptionAttribute](xref:McMaster.Extensions.CommandLineUtils.OptionAttribute)
17+
- [ArgumentAttribute](xref:McMaster.Extensions.CommandLineUtils.ArgumentAttribute)
18+
- [CommandAttribute](xref:McMaster.Extensions.CommandLineUtils.CommandAttribute)
19+
- [SubcommandAttribute](xref:McMaster.Extensions.CommandLineUtils.SubcommandAttribute)
20+
- [HelpOptionAttribute](xref:McMaster.Extensions.CommandLineUtils.HelpOptionAttribute)
21+
22+
Other commonly used types include
23+
24+
- [DotNetExe](xref:McMaster.Extensions.CommandLineUtils.DotNetExe)
25+
- [Prompt](xref:McMaster.Extensions.CommandLineUtils.Prompt)
26+
- [ArgumentEscaper](xref:McMaster.Extensions.CommandLineUtils.ArgumentEscaper)
27+
- [IConsole](xref:McMaster.Extensions.CommandLineUtils.IConsole)

docfx_project/docfx.json

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{
2+
"metadata": [
3+
{
4+
"src": [
5+
{
6+
"files": [
7+
"src/**.csproj"
8+
],
9+
"src": "../",
10+
"exclude": [
11+
"**/bin/**",
12+
"**/obj/**"
13+
]
14+
}
15+
],
16+
"dest": "obj/api/",
17+
"properties": {
18+
"TargetFramework": "netstandard2.0"
19+
}
20+
}
21+
],
22+
"build": {
23+
"content": [
24+
{
25+
"files": "**.yml",
26+
"exclude": [
27+
"**/obj/**",
28+
"**.meta"
29+
],
30+
"src": "obj/api",
31+
"dest": "api"
32+
},
33+
{
34+
"files": [
35+
"**.md",
36+
"**.yml"
37+
],
38+
"exclude": [
39+
"**/obj/**",
40+
"**.meta"
41+
]
42+
}
43+
],
44+
"resource": [
45+
{
46+
"files": [
47+
"**/images/**"
48+
],
49+
"exclude": [
50+
"**/obj/**",
51+
"**.meta"
52+
]
53+
},
54+
{
55+
"files": "schemas/**schema.json",
56+
"src": ".."
57+
}
58+
],
59+
"overwrite": "apispec/*.md",
60+
"dest": "../docs/",
61+
"template": [
62+
"default"
63+
],
64+
"postProcessors": [
65+
"ExtractSearchIndex"
66+
],
67+
"noLangKeyword": false,
68+
"keepFileLink": false,
69+
"cleanupCacheHistory": false,
70+
"disableGitFeatures": false,
71+
"globalMetadata": {
72+
"_appFooter": "Generated with docfx"
73+
}
74+
}
75+
}

docfx_project/index.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
CommandLineUtils
2+
================
3+
4+
**https://nuget.org/packages/McMaster.Extensions.CommandLineUtils**
5+
6+
This project is a fork of [Microsoft.Extensions.CommandLineUtils](https://github.com/aspnet/Common), which is no longer under [active development](https://github.com/aspnet/Common/issues/257). This fork, on the other hand, will continue release updates and take contributions.
7+
8+
## API Reference
9+
10+
See the [API Reference](./api/) for more details.
11+
12+
## Install
13+
14+
Install the NuGet package into your project.
15+
16+
17+
```
18+
PM> Install-Package McMaster.Extensions.CommandLineUtils
19+
```
20+
```
21+
$ dotnet add package McMaster.Extensions.CommandLineUtils
22+
```
23+
```xml
24+
<ItemGroup>
25+
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="2.0.1" />
26+
</ItemGroup>
27+
```
28+
29+
Pre-release builds and symbols: https://www.myget.org/gallery/natemcmaster/
30+
31+
## Usage
32+
33+
See [samples](https://github.com/natemcmaster/CommandLineUtils/tree/master/samples) for more examples.
34+
35+
`CommandLineApplication` is the main entry point for most console apps parsing. There are two primary ways to use this API, using the builder pattern and attributes.
36+
37+
### Attribute API
38+
39+
```c#
40+
using System;
41+
using McMaster.Extensions.CommandLineUtils;
42+
43+
[HelpOption]
44+
public class Program
45+
{
46+
public static int Main(string[] args)
47+
=> CommandLineApplication.Execute<Program>(args);
48+
49+
[Option(Description = "The subject")]
50+
public string Subject { get; }
51+
52+
private void OnExecute()
53+
{
54+
var subject = Subject ?? "world";
55+
Console.WriteLine($"Hello {subject}!");
56+
}
57+
}
58+
```
59+
60+
### Builder API
61+
62+
63+
```c#
64+
using System;
65+
using McMaster.Extensions.CommandLineUtils;
66+
67+
public class Program
68+
{
69+
public static int Main(string[] args)
70+
{
71+
var app = new CommandLineApplication();
72+
73+
app.HelpOption();
74+
var optionSubject = app.Option("-s|--subject <SUBJECT>", "The subject", CommandOptionType.SingleValue);
75+
76+
app.OnExecute(() =>
77+
{
78+
var subject = optionSubject.HasValue()
79+
? optionSubject.Value()
80+
: "world";
81+
82+
Console.WriteLine($"Hello {subject}!");
83+
return 0;
84+
});
85+
86+
return app.Execute(args);
87+
}
88+
}
89+
90+
```

docfx_project/toc.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
- name: Home
2+
href: index.md
3+
- name: API Documentation
4+
href: api/index.md
5+
- name: GitHub
6+
href: https://github.com/natemcmaster/CommandLineUtils

docs.ps1

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#requires -version 5
2+
param(
3+
[switch]$Serve
4+
)
5+
$ErrorActionPreference = 'Stop'
6+
Set-StrictMode -Version 2
7+
8+
$docfxVersion = '2.28.2'
9+
$docfxRoot = "$PSScriptRoot/.nuget/docfx.console/$docfxVersion"
10+
$docfx = "$docfxRoot/tools/docfx.exe"
11+
if (-not (Test-Path $docfx)) {
12+
mkdir -p $docfxRoot -ErrorAction Ignore | Out-Null
13+
$temp = (New-TemporaryFile).FullName + ".zip"
14+
Invoke-WebRequest "https://www.nuget.org/api/v2/package/docfx.console/$docfxVersion" -O $temp
15+
Expand-Archive $temp -DestinationPath $docfxRoot
16+
Remove-Item $temp
17+
}
18+
19+
$arguments = @()
20+
if ($Serve) {
21+
$arguments += '--serve'
22+
}
23+
& $docfx docfx_project/docfx.json @arguments

0 commit comments

Comments
 (0)