Move Spectre.Console.Cli to it's own package

This commit is contained in:
Patrik Svensson
2022-05-14 22:56:36 +02:00
committed by Patrik Svensson
parent b600832e00
commit 36ca22ffac
262 changed files with 736 additions and 48 deletions

View File

@ -0,0 +1,5 @@
Error: An error occured when parsing template.
Arguments can not contain options.
--foo <BAR>
^^^^^ Not permitted

View File

@ -0,0 +1,5 @@
Error: An error occured when parsing template.
Encountered invalid character '$' in option name.
--f$oo
^ Invalid character

View File

@ -0,0 +1,5 @@
Error: An error occured when parsing template.
Encountered invalid character '$' in value name.
-f|--foo <F$OO>
^ Invalid character

View File

@ -0,0 +1,5 @@
Error: An error occured when parsing template.
Long option names must consist of more than one character.
--f
^ Invalid option name

View File

@ -0,0 +1,5 @@
Error: An error occured when parsing template.
No long or short name for option has been specified.
<FOO>
^^^^^ Missing option. Was this meant to be an argument?

View File

@ -0,0 +1,5 @@
Error: An error occured when parsing template.
Multiple option values are not supported.
-f|--foo <FOO> <BAR>
^^^^^ Too many option values

View File

@ -0,0 +1,5 @@
Error: An error occured when parsing template.
Multiple values are not supported.
<FOO> <BAR>
^^^^^ Too many values

View File

@ -0,0 +1,5 @@
Error: An error occured when parsing template.
Option names cannot start with a digit.
--1foo
^^^^ Invalid option name

View File

@ -0,0 +1,5 @@
Error: An error occured when parsing template.
Options without name are not allowed.
--foo|-
^ Missing option name

View File

@ -0,0 +1,5 @@
Error: An error occured when parsing template.
Short option names can not be longer than one character.
--foo|-bar
^^^ Invalid option name

View File

@ -0,0 +1,5 @@
Error: An error occured when parsing template.
Encountered unexpected character '$'.
<FOO> $ <BAR>
^ Unexpected character

View File

@ -0,0 +1,5 @@
Error: An error occured when parsing template.
Encountered unterminated value name 'BAR'.
--foo|-f <BAR
^^^^ Unterminated value name

View File

@ -0,0 +1,5 @@
Error: An error occured when parsing template.
Values without name are not allowed.
<>
^^ Missing value name

View File

@ -0,0 +1,12 @@
USAGE:
myapp <FOO> <BAR> <BAZ> <CORGI> [QUX] [OPTIONS]
ARGUMENTS:
<FOO>
<BAR>
<BAZ>
<CORGI>
[QUX]
OPTIONS:
-h, --help Prints help information

View File

@ -0,0 +1,14 @@
USAGE:
myapp cat [LEGS] [OPTIONS] <COMMAND>
ARGUMENTS:
[LEGS] The number of legs
OPTIONS:
-h, --help Prints help information
-a, --alive Indicates whether or not the animal is alive
-n, --name <VALUE>
--agility <VALUE> The agility between 0 and 100
COMMANDS:
lion <TEETH> The lion command

View File

@ -0,0 +1,16 @@
USAGE:
myapp animal [LEGS] [OPTIONS] <COMMAND>
EXAMPLES:
myapp animal --help
ARGUMENTS:
[LEGS] The number of legs
OPTIONS:
-h, --help Prints help information
-a, --alive Indicates whether or not the animal is alive
COMMANDS:
dog <AGE> The dog command
horse The horse command

View File

@ -0,0 +1,13 @@
USAGE:
myapp <TEETH> [LEGS] [OPTIONS]
ARGUMENTS:
<TEETH> The number of teeth the lion has
[LEGS] The number of legs
OPTIONS:
-h, --help Prints help information
-a, --alive Indicates whether or not the animal is alive
-n, --name <VALUE>
--agility <VALUE> The agility between 0 and 100
-c <CHILDREN> The number of children the lion has

View File

@ -0,0 +1,16 @@
USAGE:
myapp <TEETH> [LEGS] [OPTIONS]
EXAMPLES:
myapp 12 -c 3
ARGUMENTS:
<TEETH> The number of teeth the lion has
[LEGS] The number of legs
OPTIONS:
-h, --help Prints help information
-a, --alive Indicates whether or not the animal is alive
-n, --name <VALUE>
--agility <VALUE> The agility between 0 and 100
-c <CHILDREN> The number of children the lion has

View File

@ -0,0 +1,9 @@
USAGE:
myapp <FOO> [OPTIONS]
ARGUMENTS:
<FOO> Dummy argument FOO
OPTIONS:
-h, --help Prints help information
--baz Dummy option BAZ

View File

@ -0,0 +1,10 @@
USAGE:
myapp [OPTIONS] <COMMAND>
OPTIONS:
-h, --help Prints help information
-v, --version Prints version information
COMMANDS:
dog <AGE> The dog command
horse The horse command

View File

@ -0,0 +1,9 @@
USAGE:
myapp cat [LEGS] lion <TEETH> [OPTIONS]
ARGUMENTS:
<TEETH> The number of teeth the lion has
OPTIONS:
-h, --help Prints help information
-c <CHILDREN> The number of children the lion has

View File

@ -0,0 +1,9 @@
USAGE:
myapp [OPTIONS] <COMMAND>
OPTIONS:
-h, --help Prints help information
-v, --version Prints version information
COMMANDS:
bar

View File

@ -0,0 +1,11 @@
USAGE:
myapp [OPTIONS] <COMMAND>
OPTIONS:
-h, --help Prints help information
-v, --version Prints version information
COMMANDS:
dog <AGE> The dog command
horse The horse command
giraffe <LENGTH> The giraffe command

View File

@ -0,0 +1,14 @@
USAGE:
myapp [OPTIONS] <COMMAND>
EXAMPLES:
myapp dog --name Rufus --age 12 --good-boy
myapp horse --name Brutus
OPTIONS:
-h, --help Prints help information
-v, --version Prints version information
COMMANDS:
dog <AGE> The dog command
horse The horse command

View File

@ -0,0 +1,14 @@
USAGE:
myapp [OPTIONS] <COMMAND>
EXAMPLES:
myapp dog --name Rufus --age 12 --good-boy
myapp horse --name Brutus
OPTIONS:
-h, --help Prints help information
-v, --version Prints version information
COMMANDS:
dog <AGE> The dog command
horse The horse command

View File

@ -0,0 +1,13 @@
USAGE:
myapp [OPTIONS] <COMMAND>
EXAMPLES:
myapp animal dog --name Rufus --age 12 --good-boy
myapp animal horse --name Brutus
OPTIONS:
-h, --help Prints help information
-v, --version Prints version information
COMMANDS:
animal The animal command

View File

@ -0,0 +1,4 @@
Error: Flags cannot be assigned a value.
dog --alive foo
^^^^^^^ Can't assign value

View File

@ -0,0 +1,4 @@
Error: Flags cannot be assigned a value.
dog -a foo
^^ Can't assign value

View File

@ -0,0 +1,4 @@
Error: Short option does not have a valid name.
dog -f0o
^ Not a valid name for a short option

View File

@ -0,0 +1,4 @@
Error: Invalid long option name.
dog --f€oo
^ Invalid character

View File

@ -0,0 +1,4 @@
Error: Invalid long option name.
dog --
^^ Did you forget the option name?

View File

@ -0,0 +1,4 @@
Error: Invalid long option name.
dog --f
^^^ Did you mean -f?

View File

@ -0,0 +1,4 @@
Error: Invalid long option name.
dog --1foo
^^^^^^ Option names cannot start with a digit

View File

@ -0,0 +1,4 @@
Error: Could not match 'baz' with an argument.
giraffe foo bar baz
^^^ Could not match to argument

View File

@ -0,0 +1,4 @@
Error: Option 'name' is defined but no value has been provided.
dog --name
^^^^^^ No value provided

View File

@ -0,0 +1,4 @@
Error: Option 'name' is defined but no value has been provided.
dog -n
^^ No value provided

View File

@ -0,0 +1,4 @@
Error: Option does not have a name.
dog -
^ Did you forget the option name?

View File

@ -0,0 +1,4 @@
Error: Expected an option value.
dog --foo=
^ Did you forget the option value?

View File

@ -0,0 +1,4 @@
Error: Expected an option value.
dog --foo:
^ Did you forget the option value?

View File

@ -0,0 +1,4 @@
Error: Expected an option value.
dog -f=
^ Did you forget the option value?

View File

@ -0,0 +1,4 @@
Error: Expected an option value.
dog -f:
^ Did you forget the option value?

View File

@ -0,0 +1,3 @@
# Raw
/c
set && pause

View File

@ -0,0 +1,4 @@
Error: Unexpected option 'foo'.
--foo
^^^^^ Did you forget the command?

View File

@ -0,0 +1,4 @@
Error: Unexpected option 'f'.
-f
^^ Did you forget the command?

View File

@ -0,0 +1,4 @@
Error: Unknown command 'cat'.
cat 14
^^^ No such command

View File

@ -0,0 +1,4 @@
Error: Unknown command 'other'.
empty other
^^^^^ No such command

View File

@ -0,0 +1,4 @@
Error: Unknown command 'bat'.
dog bat 14
^^^ Did you mean 'cat'?

View File

@ -0,0 +1,4 @@
Error: Unknown command 'bat'.
bat 14
^^^ Did you mean 'cat'?

View File

@ -0,0 +1,4 @@
Error: Unknown command 'bat'.
bat
^^^ Did you mean 'cat'?

View File

@ -0,0 +1,4 @@
Error: Unknown command 'bat'.
dog bat
^^^ Did you mean 'cat'?

View File

@ -0,0 +1,4 @@
Error: Unknown command 'bat'.
qux bat
^^^ Did you mean 'bar'?

View File

@ -0,0 +1,4 @@
Error: Unknown command 'bat'.
foo qux bat
^^^ Did you mean 'bar'?

View File

@ -0,0 +1,4 @@
Error: Unknown option 'unknown'.
dog --unknown
^^^^^^^^^ Unknown option

View File

@ -0,0 +1,4 @@
Error: Unknown option 'u'.
dog -u
^^ Unknown option

View File

@ -0,0 +1,4 @@
Error: Encountered unterminated quoted string 'Rufus'.
--name "Rufus
^^^^^^ Did you forget the closing quotation mark?

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Model>
<!--DEFAULT COMMAND-->
<Command Name="__default_command" IsBranch="false" IsDefault="true" ClrType="Spectre.Console.Tests.Data.HiddenOptionsCommand" Settings="Spectre.Console.Tests.Data.HiddenOptionSettings">
<Parameters>
<Argument Name="FOO" Position="0" Required="true" Kind="scalar" ClrType="System.Int32">
<Description>Dummy argument FOO</Description>
</Argument>
<Option Short="" Long="baz" Value="NULL" Required="false" Kind="scalar" ClrType="System.Int32">
<Description>Dummy option BAZ</Description>
</Option>
</Parameters>
</Command>
</Model>

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<Model>
<!--ANIMAL-->
<Command Name="animal" IsBranch="true" Settings="Spectre.Console.Tests.Data.AnimalSettings">
<Parameters>
<Argument Name="LEGS" Position="0" Required="false" Kind="scalar" ClrType="System.Int32">
<Description>The number of legs.</Description>
<Validators>
<Validator ClrType="Spectre.Console.Tests.Data.EvenNumberValidatorAttribute" Message="Animals must have an even number of legs." />
<Validator ClrType="Spectre.Console.Tests.Data.PositiveNumberValidatorAttribute" Message="Number of legs must be greater than 0." />
</Validators>
</Argument>
<Option Short="a" Long="alive,not-dead" Value="NULL" Required="false" Kind="flag" ClrType="System.Boolean">
<Description>Indicates whether or not the animal is alive.</Description>
</Option>
</Parameters>
<!--MAMMAL-->
<Command Name="mammal" IsBranch="true" Settings="Spectre.Console.Tests.Data.MammalSettings">
<Parameters>
<Option Short="n,p" Long="name,pet-name" Value="VALUE" Required="false" Kind="scalar" ClrType="System.String" />
</Parameters>
<!--DOG-->
<Command Name="dog" IsBranch="false" ClrType="Spectre.Console.Tests.Data.DogCommand" Settings="Spectre.Console.Tests.Data.DogSettings">
<Parameters>
<Argument Name="AGE" Position="0" Required="true" Kind="scalar" ClrType="System.Int32" />
<Option Short="g" Long="good-boy" Value="NULL" Required="false" Kind="flag" ClrType="System.Boolean" />
</Parameters>
</Command>
<!--HORSE-->
<Command Name="horse" IsBranch="false" ClrType="Spectre.Console.Tests.Data.HorseCommand" Settings="Spectre.Console.Tests.Data.MammalSettings">
<Parameters>
<Option Shadowed="true" Short="n,p" Long="name,pet-name" Value="VALUE" Required="false" Kind="scalar" ClrType="System.String" />
</Parameters>
</Command>
</Command>
</Command>
</Model>

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<Model>
<!--DOG-->
<Command Name="dog" IsBranch="false" ClrType="Spectre.Console.Tests.Data.DogCommand" Settings="Spectre.Console.Tests.Data.DogSettings">
<Parameters>
<Argument Name="LEGS" Position="0" Required="false" Kind="scalar" ClrType="System.Int32">
<Description>The number of legs.</Description>
<Validators>
<Validator ClrType="Spectre.Console.Tests.Data.EvenNumberValidatorAttribute" Message="Animals must have an even number of legs." />
<Validator ClrType="Spectre.Console.Tests.Data.PositiveNumberValidatorAttribute" Message="Number of legs must be greater than 0." />
</Validators>
</Argument>
<Argument Name="AGE" Position="1" Required="true" Kind="scalar" ClrType="System.Int32" />
<Option Short="a" Long="alive,not-dead" Value="NULL" Required="false" Kind="flag" ClrType="System.Boolean">
<Description>Indicates whether or not the animal is alive.</Description>
</Option>
<Option Short="g" Long="good-boy" Value="NULL" Required="false" Kind="flag" ClrType="System.Boolean" />
<Option Short="n,p" Long="name,pet-name" Value="VALUE" Required="false" Kind="scalar" ClrType="System.String" />
</Parameters>
</Command>
</Model>

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<Model>
<!--ANIMAL-->
<Command Name="animal" IsBranch="true" Settings="Spectre.Console.Tests.Data.AnimalSettings">
<Parameters>
<Argument Name="LEGS" Position="0" Required="false" Kind="scalar" ClrType="System.Int32">
<Description>The number of legs.</Description>
<Validators>
<Validator ClrType="Spectre.Console.Tests.Data.EvenNumberValidatorAttribute" Message="Animals must have an even number of legs." />
<Validator ClrType="Spectre.Console.Tests.Data.PositiveNumberValidatorAttribute" Message="Number of legs must be greater than 0." />
</Validators>
</Argument>
<Option Short="a" Long="alive,not-dead" Value="NULL" Required="false" Kind="flag" ClrType="System.Boolean">
<Description>Indicates whether or not the animal is alive.</Description>
</Option>
</Parameters>
<!--DOG-->
<Command Name="dog" IsBranch="false" ClrType="Spectre.Console.Tests.Data.DogCommand" Settings="Spectre.Console.Tests.Data.DogSettings">
<Parameters>
<Argument Name="AGE" Position="0" Required="true" Kind="scalar" ClrType="System.Int32" />
<Option Short="g" Long="good-boy" Value="NULL" Required="false" Kind="flag" ClrType="System.Boolean" />
<Option Short="n,p" Long="name,pet-name" Value="VALUE" Required="false" Kind="scalar" ClrType="System.String" />
</Parameters>
</Command>
<!--HORSE-->
<Command Name="horse" IsBranch="false" ClrType="Spectre.Console.Tests.Data.HorseCommand" Settings="Spectre.Console.Tests.Data.MammalSettings">
<Parameters>
<Option Short="n,p" Long="name,pet-name" Value="VALUE" Required="false" Kind="scalar" ClrType="System.String" />
</Parameters>
</Command>
</Command>
</Model>

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<Model>
<!--ANIMAL-->
<Command Name="animal" IsBranch="true" Settings="Spectre.Console.Tests.Data.AnimalSettings">
<Parameters>
<Argument Name="LEGS" Position="0" Required="false" Kind="scalar" ClrType="System.Int32">
<Description>The number of legs.</Description>
<Validators>
<Validator ClrType="Spectre.Console.Tests.Data.EvenNumberValidatorAttribute" Message="Animals must have an even number of legs." />
<Validator ClrType="Spectre.Console.Tests.Data.PositiveNumberValidatorAttribute" Message="Number of legs must be greater than 0." />
</Validators>
</Argument>
<Option Short="a" Long="alive,not-dead" Value="NULL" Required="false" Kind="flag" ClrType="System.Boolean">
<Description>Indicates whether or not the animal is alive.</Description>
</Option>
</Parameters>
<!--DOG-->
<Command Name="dog" IsBranch="false" ClrType="Spectre.Console.Tests.Data.DogCommand" Settings="Spectre.Console.Tests.Data.DogSettings">
<Parameters>
<Argument Name="AGE" Position="0" Required="true" Kind="scalar" ClrType="System.Int32" />
<Option Short="g" Long="good-boy" Value="NULL" Required="false" Kind="flag" ClrType="System.Boolean" />
<Option Short="n,p" Long="name,pet-name" Value="VALUE" Required="false" Kind="scalar" ClrType="System.String" />
</Parameters>
</Command>
</Command>
</Model>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<Model>
<!--CMD-->
<Command Name="cmd" IsBranch="false" ClrType="Spectre.Console.Tests.Data.OptionVectorCommand" Settings="Spectre.Console.Tests.Data.OptionVectorSettings">
<Parameters>
<Option Short="" Long="bar" Value="NULL" Required="false" Kind="vector" ClrType="System.Int32[]" />
<Option Short="" Long="foo" Value="NULL" Required="false" Kind="vector" ClrType="System.String[]" />
</Parameters>
</Command>
</Model>

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<Model>
<!--DEFAULT COMMAND-->
<Command Name="__default_command" IsBranch="false" IsDefault="true" ClrType="Spectre.Console.Tests.Data.DogCommand" Settings="Spectre.Console.Tests.Data.DogSettings">
<Parameters>
<Argument Name="LEGS" Position="0" Required="false" Kind="scalar" ClrType="System.Int32">
<Description>The number of legs.</Description>
<Validators>
<Validator ClrType="Spectre.Console.Tests.Data.EvenNumberValidatorAttribute" Message="Animals must have an even number of legs." />
<Validator ClrType="Spectre.Console.Tests.Data.PositiveNumberValidatorAttribute" Message="Number of legs must be greater than 0." />
</Validators>
</Argument>
<Argument Name="AGE" Position="1" Required="true" Kind="scalar" ClrType="System.Int32" />
<Option Short="a" Long="alive,not-dead" Value="NULL" Required="false" Kind="flag" ClrType="System.Boolean">
<Description>Indicates whether or not the animal is alive.</Description>
</Option>
<Option Short="g" Long="good-boy" Value="NULL" Required="false" Kind="flag" ClrType="System.Boolean" />
<Option Short="n,p" Long="name,pet-name" Value="VALUE" Required="false" Kind="scalar" ClrType="System.String" />
</Parameters>
</Command>
<!--HORSE-->
<Command Name="horse" IsBranch="false" ClrType="Spectre.Console.Tests.Data.HorseCommand" Settings="Spectre.Console.Tests.Data.MammalSettings">
<Parameters>
<Argument Name="LEGS" Position="0" Required="false" Kind="scalar" ClrType="System.Int32">
<Description>The number of legs.</Description>
<Validators>
<Validator ClrType="Spectre.Console.Tests.Data.EvenNumberValidatorAttribute" Message="Animals must have an even number of legs." />
<Validator ClrType="Spectre.Console.Tests.Data.PositiveNumberValidatorAttribute" Message="Number of legs must be greater than 0." />
</Validators>
</Argument>
<Option Short="a" Long="alive,not-dead" Value="NULL" Required="false" Kind="flag" ClrType="System.Boolean">
<Description>Indicates whether or not the animal is alive.</Description>
</Option>
<Option Short="n,p" Long="name,pet-name" Value="VALUE" Required="false" Kind="scalar" ClrType="System.String" />
</Parameters>
</Command>
</Model>