diff --git a/AutoRest/AutoRest.Core/AutoRest.cs b/AutoRest/AutoRest.Core/AutoRest.cs index 2041e7ac8157c..d732ff6639c8b 100644 --- a/AutoRest/AutoRest.Core/AutoRest.cs +++ b/AutoRest/AutoRest.Core/AutoRest.cs @@ -50,6 +50,8 @@ public static void Generate(Settings settings) throw ErrorManager.CreateError(exception, Resources.ErrorGeneratingClientModel, exception.Message); } CodeGenerator codeGenerator = ExtensionsLoader.GetCodeGenerator(settings); + Logger.WriteOutput(codeGenerator.UsageInstructions); + settings.Validate(); try { diff --git a/AutoRest/AutoRest.Core/Extensibility/ExtensionsLoader.cs b/AutoRest/AutoRest.Core/Extensibility/ExtensionsLoader.cs index 4aefb53b87e5c..8f4cb29654714 100644 --- a/AutoRest/AutoRest.Core/Extensibility/ExtensionsLoader.cs +++ b/AutoRest/AutoRest.Core/Extensibility/ExtensionsLoader.cs @@ -77,7 +77,7 @@ public static CodeGenerator GetCodeGenerator(Settings settings) /// Modeler specified in Settings.Modeler public static Modeler GetModeler(Settings settings) { - Logger.LogInfo(Resources.ModelerInitialized); + Logger.LogInfo(Resources.InitializingModeler); if (settings == null) { throw new ArgumentNullException("settings", "settings or settings.Modeler cannot be null."); diff --git a/AutoRest/AutoRest.Core/Logging/Logger.cs b/AutoRest/AutoRest.Core/Logging/Logger.cs index 846c274678be2..e003f217ceb6a 100644 --- a/AutoRest/AutoRest.Core/Logging/Logger.cs +++ b/AutoRest/AutoRest.Core/Logging/Logger.cs @@ -37,6 +37,17 @@ public static void LogInfo(string message, params object[] args) Entries.Add(new LogEntry(LogEntrySeverity.Info, string.Format(CultureInfo.InvariantCulture, message, args))); } + /// + /// An abstraction for the core to output text (ie not err,warning, or info) + /// + /// + /// + public static void WriteOutput(string message, params object[] args) + { + Console.ResetColor(); + Console.WriteLine(message, args); + } + /// /// Logs a message of severity LogEntrySeverity.Warning. /// diff --git a/AutoRest/AutoRest.Core/Properties/Resources.Designer.cs b/AutoRest/AutoRest.Core/Properties/Resources.Designer.cs index c4fe1ce315511..2ef7dbdc586ae 100644 --- a/AutoRest/AutoRest.Core/Properties/Resources.Designer.cs +++ b/AutoRest/AutoRest.Core/Properties/Resources.Designer.cs @@ -177,6 +177,15 @@ internal static string InitializingCodeGenerator { } } + /// + /// Looks up a localized string similar to Initializing modeler.. + /// + internal static string InitializingModeler { + get { + return ResourceManager.GetString("InitializingModeler", resourceCulture); + } + } + /// /// Looks up a localized string similar to Property name {0} cannot be used as an Identifier, as it contains only invalid characters.. /// @@ -196,7 +205,7 @@ internal static string LanguageDoesNotSupportSingleFileGeneration { } /// - /// Looks up a localized string similar to Initializing modeler.. + /// Looks up a localized string similar to Successfully initialized modeler {0} v {1}.. /// internal static string ModelerInitialized { get { diff --git a/AutoRest/AutoRest.Core/Properties/Resources.resx b/AutoRest/AutoRest.Core/Properties/Resources.resx index 50a7bfb31d3e8..18688acae3326 100644 --- a/AutoRest/AutoRest.Core/Properties/Resources.resx +++ b/AutoRest/AutoRest.Core/Properties/Resources.resx @@ -156,6 +156,9 @@ Initializing code generator. + + Initializing modeler. + Property name {0} cannot be used as an Identifier, as it contains only invalid characters. @@ -163,7 +166,7 @@ '{0}' code generator does not support code generation to a single file. - Initializing modeler. + Successfully initialized modeler {0} v {1}. {0} (already used in {1}) diff --git a/AutoRest/AutoRest.Core/Settings.cs b/AutoRest/AutoRest.Core/Settings.cs index 94c9fb7f524de..63675cf0e46b4 100644 --- a/AutoRest/AutoRest.Core/Settings.cs +++ b/AutoRest/AutoRest.Core/Settings.cs @@ -195,6 +195,12 @@ public string Header [SettingsAlias("help")] public bool ShowHelp { get; set; } + /// + /// If set to true, print out all messages. + /// + [SettingsAlias("verbose")] + public bool Verbose { get; set; } + /// /// PackageName of then generated code package. Should be then names wanted for the package in then package manager. /// diff --git a/AutoRest/AutoRest/Program.cs b/AutoRest/AutoRest/Program.cs index f7bdf406b1066..9871e76af2e3b 100644 --- a/AutoRest/AutoRest/Program.cs +++ b/AutoRest/AutoRest/Program.cs @@ -33,8 +33,6 @@ private static int Main(string[] args) else { AutoRest.Generate(settings); - var codeGenerator = ExtensionsLoader.GetCodeGenerator(settings); - Console.WriteLine(codeGenerator.UsageInstructions); } } catch (CodeGenerationException) @@ -75,17 +73,21 @@ private static int Main(string[] args) } } - Logger.WriteErrors(Console.Error, - args.Any(a => "-Verbose".Equals(a, StringComparison.OrdinalIgnoreCase))); - - Logger.WriteWarnings(Console.Out); - + Console.ResetColor(); // Include LogEntrySeverity.Infos for verbose logging. if (args.Any(a => "-Verbose".Equals(a, StringComparison.OrdinalIgnoreCase))) { + Console.ForegroundColor = ConsoleColor.White; Logger.WriteInfos(Console.Out); } + Console.ForegroundColor = ConsoleColor.Yellow; + Logger.WriteWarnings(Console.Out); + + Console.ForegroundColor = ConsoleColor.Red; + Logger.WriteErrors(Console.Error, + args.Any(a => "-Verbose".Equals(a, StringComparison.OrdinalIgnoreCase))); + Console.ResetColor(); } } diff --git a/Documentation/cli.md b/Documentation/cli.md index 6ffe3f7790b80..4dddaeec8a919 100644 --- a/Documentation/cli.md +++ b/Documentation/cli.md @@ -1,10 +1,10 @@ #AutoRest Command Line Interface Documentation ##Syntax -`AutoRest.exe -Input [-Namespace ] [-OutputDirectory ] [-CodeGenerator ] [-Modeler ] [-ClientName ] [-PayloadFlatteningThreshold ] [-Header ] [-AddCredentials ] [-OutputFileName ]` +`AutoRest.exe -Input [-Verbose] [-Namespace ] [-OutputDirectory ] [-CodeGenerator ] [-Modeler ] [-ClientName ] [-PayloadFlatteningThreshold ] [-Header ] [-AddCredentials ] [-OutputFileName ]` ##Parameters - **-Input** The location of the input specification. Aliases: -i, -input + **-Input** The location of the input specification. Aliases: -i, -input . The input file may be either in JSON or YAML format. **-Namespace** The namespace to use for generated code. Aliases: -n @@ -23,28 +23,29 @@ **-AddCredentials** If true, the generated client includes a ServiceClientCredentials property and constructor parameter. Authentication behaviors are implemented by extending the ServiceClientCredentials type. **-OutputFileName** If set, will cause generated code to be output to a single file. Not supported by all code generators. - + + **-Verbose** If set, will output verbose diagnostic messages. ##Code Generators - **-Ruby** Generic Ruby code generator. + **Ruby** Generic Ruby code generator. - **-Azure.Ruby** Azure specific Ruby code generator. + **Azure.Ruby** Azure specific Ruby code generator. - **-CSharp** Generic C# code generator. + **CSharp** Generic C# code generator. - **-Azure.CSharp** Azure specific C# code generator. + **Azure.CSharp** Azure specific C# code generator. - **-NodeJS** Generic NodeJS code generator. + **NodeJS** Generic NodeJS code generator. - **-Azure.NodeJS** Azure specific NodeJS code generator. + **Azure.NodeJS** Azure specific NodeJS code generator. - **-Java** Generic Java code generator. + **Java** Generic Java code generator. - **-Azure.Java** Azure specific Java code generator. + **Azure.Java** Azure specific Java code generator. - **-Python** Generic Python code generator. + **Python** Generic Python code generator. - **-Azure.Python** Azure specific Python code generator. + **Azure.Python** Azure specific Python code generator. ##Code Generator Specific Settings ###CSharp diff --git a/Tools/verify-settings.ps1 b/Tools/verify-settings.ps1 index bb419ddebaf6b..b8f0ee93cc74a 100644 --- a/Tools/verify-settings.ps1 +++ b/Tools/verify-settings.ps1 @@ -114,7 +114,7 @@ function which( if( $env:path ) { foreach( $dir in $env:path.Split(";")) { foreach( $ext in (";.ps1;"+$env:pathext).split(";")) { - if( $dir -and (resolve-path $dir) ) { + if( $dir -and (resolve-path $dir -ea 0 ) ) { $p = join-path $dir "$cmd$ext" if( exists $p ) { if( Validate -exe $p $arch $include $exclude $minimumVersion ) {