mirror of
				https://github.com/nsnail/spectre.console.git
				synced 2025-11-01 01:25:27 +08:00 
			
		
		
		
	Do not truncate command table
Temporary fix for commands not showing up if they are missing a description. This is really a bug in the table rendering and should be fixed there at some point. Closes #192
This commit is contained in:
		 Patrik Svensson
					Patrik Svensson
				
			
				
					committed by
					
						 Patrik Svensson
						Patrik Svensson
					
				
			
			
				
	
			
			
			 Patrik Svensson
						Patrik Svensson
					
				
			
						parent
						
							4e2251fd62
						
					
				
				
					commit
					241423dd16
				
			| @@ -0,0 +1,5 @@ | ||||
| <ProjectConfiguration> | ||||
|   <Settings> | ||||
|     <XUnit2Enabled>False</XUnit2Enabled> | ||||
|   </Settings> | ||||
| </ProjectConfiguration> | ||||
| @@ -0,0 +1,16 @@ | ||||
| using System.Diagnostics.CodeAnalysis; | ||||
| using Spectre.Console.Cli; | ||||
|  | ||||
| namespace Spectre.Console.Tests.Data | ||||
| { | ||||
|     public sealed class NoDescriptionCommand : Command<EmptyCommandSettings> | ||||
|     { | ||||
|         [CommandOption("-f|--foo <VALUE>")] | ||||
|         public int Foo { get; set; } | ||||
|  | ||||
|         public override int Execute([NotNull] CommandContext context, [NotNull] EmptyCommandSettings settings) | ||||
|         { | ||||
|             return 0; | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,9 @@ | ||||
| USAGE: | ||||
|     myapp [OPTIONS] <COMMAND> | ||||
|  | ||||
| OPTIONS: | ||||
|     -h, --help       Prints help information | ||||
|     -v, --version    Prints version information | ||||
|  | ||||
| COMMANDS: | ||||
|     bar | ||||
| @@ -226,6 +226,24 @@ namespace Spectre.Console.Tests.Unit.Cli | ||||
|                 // Then | ||||
|                 return Verifier.Verify(output); | ||||
|             } | ||||
|  | ||||
|             [Fact] | ||||
|             public Task Should_Not_Show_Truncated_Command_Table_If_Commands_Are_Missing_Description() | ||||
|             { | ||||
|                 // Given | ||||
|                 var fixture = new CommandAppFixture(); | ||||
|                 fixture.Configure(configurator => | ||||
|                 { | ||||
|                     configurator.SetApplicationName("myapp"); | ||||
|                     configurator.AddCommand<NoDescriptionCommand>("bar"); | ||||
|                 }); | ||||
|  | ||||
|                 // When | ||||
|                 var (_, output, _, _) = fixture.Run("--help"); | ||||
|  | ||||
|                 // Then | ||||
|                 return Verifier.Verify(output); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
							
								
								
									
										6
									
								
								src/Spectre.Console.v3.ncrunchsolution
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								src/Spectre.Console.v3.ncrunchsolution
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,6 @@ | ||||
| <SolutionConfiguration> | ||||
|   <Settings> | ||||
|     <AllowParallelTestExecution>True</AllowParallelTestExecution> | ||||
|     <SolutionConfigured>True</SolutionConfigured> | ||||
|   </Settings> | ||||
| </SolutionConfiguration> | ||||
| @@ -244,13 +244,13 @@ namespace Spectre.Console.Cli.Internal | ||||
|                 { | ||||
|                     grid.AddRow( | ||||
|                         $"[silver]<{argument.Name.EscapeMarkup()}>[/]", | ||||
|                         argument.Description?.TrimEnd('.') ?? string.Empty); | ||||
|                         argument.Description?.TrimEnd('.') ?? " "); | ||||
|                 } | ||||
|                 else | ||||
|                 { | ||||
|                     grid.AddRow( | ||||
|                         $"[grey][[{argument.Name.EscapeMarkup()}]][/]", | ||||
|                         argument.Description?.TrimEnd('.') ?? string.Empty); | ||||
|                         argument.Description?.TrimEnd('.') ?? " "); | ||||
|                 } | ||||
|             } | ||||
|  | ||||
| @@ -324,7 +324,7 @@ namespace Spectre.Console.Cli.Internal | ||||
|             { | ||||
|                 grid.AddRow( | ||||
|                     GetOptionParts(option), | ||||
|                     option.Description?.TrimEnd('.') ?? string.Empty); | ||||
|                     option.Description?.TrimEnd('.') ?? " "); | ||||
|             } | ||||
|  | ||||
|             grid.AddEmptyRow(); | ||||
| @@ -370,7 +370,7 @@ namespace Spectre.Console.Cli.Internal | ||||
|  | ||||
|                 grid.AddRow( | ||||
|                     arguments.ToString().TrimEnd(), | ||||
|                     child.Description?.TrimEnd('.') ?? string.Empty); | ||||
|                     child.Description?.TrimEnd('.') ?? " "); | ||||
|             } | ||||
|  | ||||
|             grid.AddEmptyRow(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user