Skip to content

Commit 77c0ad8

Browse files
committed
Renamed SubCommand sample to Subcommand
1 parent be0b015 commit 77c0ad8

15 files changed

Lines changed: 257 additions & 265 deletions

docs/Subcommands.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ command. The remaining arguments are arguments to that command. You cannot have
1414
not associated with a command using the subcommand functionality in Ookii.CommandLine, though you
1515
can still easily define [common arguments](#multiple-commands-with-common-arguments).
1616

17-
For example, the [subcommand sample](../src/Samples/SubCommand) can be invoked as follows:
17+
For example, the [subcommand sample](../src/Samples/Subcommand) can be invoked as follows:
1818

1919
```text
20-
./SubCommand read file.txt -Encoding utf-16
20+
./Subcommand read file.txt -Encoding utf-16
2121
```
2222

2323
This command line invokes the command named `read`, and passes the remaining arguments to that
@@ -301,7 +301,7 @@ whether this works depends on the command's implementation of that method. If yo
301301
However, in all cases, it's strongly recommended to use [`RunCommandAsync()`][] if you use any
302302
asynchronous commands.
303303

304-
Check out the [tutorial](Tutorial.md) and the [subcommand sample](../src/Samples/SubCommand) for
304+
Check out the [tutorial](Tutorial.md) and the [subcommand sample](../src/Samples/Subcommand) for
305305
more detailed examples of how to create and use commands.
306306

307307
### Other assemblies
@@ -471,10 +471,10 @@ help automatically.
471471
## Subcommand usage help
472472

473473
Since subcommands are created using the [`CommandLineParser`][], they support showing usage help when
474-
parsing errors occur, or the `-Help` argument is used. For example, with the [subcommand sample](../src/Samples/SubCommand) you could run the following to get help on the `read` command:
474+
parsing errors occur, or the `-Help` argument is used. For example, with the [subcommand sample](../src/Samples/Subcommand) you could run the following to get help on the `read` command:
475475

476476
```text
477-
./SubCommand read -help
477+
./Subcommand read -help
478478
```
479479

480480
In addition, the [`CommandManager`][] also prints usage help if no command name was supplied, or the
@@ -484,7 +484,7 @@ a list of commands, with their descriptions. This is what that looks like for th
484484
```text
485485
Subcommand sample for Ookii.CommandLine.
486486
487-
Usage: SubCommand <command> [arguments]
487+
Usage: Subcommand <command> [arguments]
488488
489489
The following commands are available:
490490
@@ -498,7 +498,7 @@ The following commands are available:
498498
write
499499
Writes lines to a file, wrapping them to the specified width.
500500
501-
Run 'SubCommand <command> -Help' for more information about a command.
501+
Run 'Subcommand <command> -Help' for more information about a command.
502502
```
503503

504504
Usage help for a [`CommandManager`][] is also created using the [`UsageWriter`][], and can be customized

src/Create-Release.ps1

0 Bytes
Binary file not shown.

src/Ookii.CommandLine.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ookii.CommandLine.Tests", "
1717
EndProject
1818
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Parser", "Samples\Parser\Parser.csproj", "{A8F86838-1956-4046-A8D9-93EBC301A468}"
1919
EndProject
20-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SubCommand", "Samples\SubCommand\SubCommand.csproj", "{329D012F-AD31-4D50-AE3C-8F500CDF62FA}"
20+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Subcommand", "Samples\Subcommand\Subcommand.csproj", "{329D012F-AD31-4D50-AE3C-8F500CDF62FA}"
2121
EndProject
2222
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{DC9CCD22-9B9B-4298-8C68-BC7A5A680F93}"
2323
EndProject

src/Samples/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Ookii.CommandLine comes with several samples that demonstrate various aspects of
1515

1616
There are two samples demonstrating how to use subcommands:
1717

18-
- The [**Subcommand sample**](SubCommand) demonstrates how to create a simple application that has
18+
- The [**Subcommand sample**](Subcommand) demonstrates how to create a simple application that has
1919
multiple subcommands.
2020
- The [**Nested commands sample**](NestedCommands) demonstrates how to create an application where commands can
2121
contain other commands. It also demonstrates how to create common arguments for multiple commands

src/Samples/SubCommand/EncodingConverter.cs

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

src/Samples/SubCommand/ExitCode.cs

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

src/Samples/SubCommand/ReadCommand.cs

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

src/Samples/SubCommand/WriteCommand.cs

Lines changed: 0 additions & 133 deletions
This file was deleted.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using Ookii.CommandLine;
2+
using System;
3+
using System.ComponentModel;
4+
using System.Globalization;
5+
using System.Text;
6+
7+
namespace SubcommandSample;
8+
9+
// A TypeConverter for the Encoding class, using the utility base class provided by
10+
// Ookii.CommandLine.
11+
internal class EncodingConverter : TypeConverterBase<Encoding>
12+
{
13+
protected override Encoding? Convert(ITypeDescriptorContext? context, CultureInfo? culture, string value)
14+
{
15+
try
16+
{
17+
return Encoding.GetEncoding(value);
18+
}
19+
catch (ArgumentException ex)
20+
{
21+
// This is the expected exception type for a type converter.
22+
throw new FormatException(ex.Message, ex);
23+
}
24+
}
25+
}

src/Samples/Subcommand/ExitCode.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace SubcommandSample;
2+
internal enum ExitCode
3+
{
4+
Success,
5+
CreateCommandFailure,
6+
ReadWriteFailure,
7+
FileExists,
8+
}

0 commit comments

Comments
 (0)