mirror of
				https://github.com/nsnail/spectre.console.git
				synced 2025-11-04 10:35:27 +08:00 
			
		
		
		
	Display the application version (if set) when a version flag is the first argument, even if a default command has been set.
This commit is contained in:
		
				
					committed by
					
						
						Patrik Svensson
					
				
			
			
				
	
			
			
			
						parent
						
							17c7a4f7d6
						
					
				
				
					commit
					dfdd129dd0
				
			@@ -29,24 +29,20 @@ internal sealed class CommandExecutor
 | 
			
		||||
        _registrar.RegisterInstance(typeof(CommandModel), model);
 | 
			
		||||
        _registrar.RegisterDependencies(model);
 | 
			
		||||
 | 
			
		||||
        // No default command?
 | 
			
		||||
        if (model.DefaultCommand == null)
 | 
			
		||||
        // Got at least one argument?
 | 
			
		||||
        var firstArgument = arguments.FirstOrDefault();
 | 
			
		||||
        if (firstArgument != null)
 | 
			
		||||
        {
 | 
			
		||||
            // Got at least one argument?
 | 
			
		||||
            var firstArgument = arguments.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))
 | 
			
		||||
            {
 | 
			
		||||
                // 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))
 | 
			
		||||
                if (configuration.Settings.ApplicationVersion != null)
 | 
			
		||||
                {
 | 
			
		||||
                    if (configuration.Settings.ApplicationVersion != null)
 | 
			
		||||
                    {
 | 
			
		||||
                        var console = configuration.Settings.Console.GetConsole();
 | 
			
		||||
                        console.MarkupLine(configuration.Settings.ApplicationVersion);
 | 
			
		||||
                        return 0;
 | 
			
		||||
                    }
 | 
			
		||||
                    var console = configuration.Settings.Console.GetConsole();
 | 
			
		||||
                    console.MarkupLine(configuration.Settings.ApplicationVersion);
 | 
			
		||||
                    return 0;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user