mirror of
				https://github.com/nsnail/spectre.console.git
				synced 2025-11-01 01:25:27 +08:00 
			
		
		
		
	Completed
This commit is contained in:
		 Frank Ray
					Frank Ray
				
			
				
					committed by
					
						 Patrik Svensson
						Patrik Svensson
					
				
			
			
				
	
			
			
			 Patrik Svensson
						Patrik Svensson
					
				
			
						parent
						
							d03c10623c
						
					
				
				
					commit
					55c763a5c2
				
			| @@ -27,15 +27,35 @@ internal sealed class CommandExecutor | ||||
|         _registrar.RegisterInstance(typeof(CommandModel), model); | ||||
|         _registrar.RegisterDependencies(model); | ||||
|  | ||||
|         // Asking for version? Kind of a hack, but it's alright. | ||||
|         // We should probably make this a bit better in the future. | ||||
|         if (args.Contains("-v") || args.Contains("--version")) | ||||
|         // No default command? | ||||
|         if (model.DefaultCommand == null) | ||||
|         { | ||||
|             var console = configuration.Settings.Console.GetConsole(); | ||||
|             console.WriteLine(ResolveApplicationVersion(configuration)); | ||||
|             return 0; | ||||
|             // Got at least one argument? | ||||
|             var firstArgument = args.FirstOrDefault(); | ||||
|             if (firstArgument != null) | ||||
|             { | ||||
|                 // Asking for version? Kind of a hack, but it's alright. | ||||
|                 // We should probably make this a bit better in the future. | ||||
|                 if (firstArgument.Equals("--version", StringComparison.OrdinalIgnoreCase) || | ||||
|                     firstArgument.Equals("-v", StringComparison.OrdinalIgnoreCase)) | ||||
|                 { | ||||
|                     var console = configuration.Settings.Console.GetConsole(); | ||||
|                     console.WriteLine(ResolveApplicationVersion(configuration)); | ||||
|                     return 0; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         //// Asking for version? Kind of a hack, but it's alright. | ||||
|         //// We should probably make this a bit better in the future. | ||||
|         //if (args.Count() > 0 && | ||||
|         //    (args.First().Equals("-v", StringComparison.OrdinalIgnoreCase) || args.First().Equals("--version", StringComparison.OrdinalIgnoreCase))) | ||||
|         //{ | ||||
|         //    var console = configuration.Settings.Console.GetConsole(); | ||||
|         //    console.WriteLine(ResolveApplicationVersion(configuration)); | ||||
|         //    return 0; | ||||
|         //} | ||||
|  | ||||
|         // Parse and map the model against the arguments. | ||||
|         var parsedResult = ParseCommandLineArguments(model, configuration.Settings, args); | ||||
|  | ||||
|   | ||||
| @@ -35,7 +35,7 @@ public sealed partial class CommandAppTests | ||||
|         } | ||||
|  | ||||
|         [Fact] | ||||
|         public void Should_Output_Application_Version_To_The_Console_With_Command() | ||||
|         public void Should_Execute_Command_Not_Output_Application_Version_To_The_Console() | ||||
|         { | ||||
|             // Given | ||||
|             var fixture = new CommandAppTester(); | ||||
| @@ -50,11 +50,12 @@ public sealed partial class CommandAppTests | ||||
|             var result = fixture.Run("empty", "--version"); | ||||
|  | ||||
|             // Then | ||||
|             result.Output.ShouldBe("1.0"); | ||||
|             result.Output.ShouldBe(string.Empty); | ||||
|             result.Context.ShouldHaveRemainingArgument("version", new[] { (string)null }); | ||||
|         } | ||||
|  | ||||
|         [Fact] | ||||
|         public void Should_Output_Application_Version_To_The_Console_With_Default_Command() | ||||
|         public void Should_Execute_Default_Command_Not_Output_Application_Version_To_The_Console() | ||||
|         { | ||||
|             // Given | ||||
|             var fixture = new CommandAppTester(); | ||||
| @@ -68,7 +69,8 @@ public sealed partial class CommandAppTests | ||||
|             var result = fixture.Run("--version"); | ||||
|  | ||||
|             // Then | ||||
|             result.Output.ShouldBe("1.0"); | ||||
|             result.Output.ShouldBe(string.Empty); | ||||
|             result.Context.ShouldHaveRemainingArgument("version", new[] { (string)null }); | ||||
|         } | ||||
|  | ||||
|         [Fact] | ||||
|   | ||||
		Reference in New Issue
	
	Block a user