Skip to content

Commit

Permalink
Fixes Azure#1019 - Verbose parameter and other costmetic issues (Azur…
Browse files Browse the repository at this point in the history
…e#1113)

* Fixes Azure#1019 - Verbose parameter and other costmetic issues

* quick fix for verify-settings script

* added documentation about JSON or YAML for input
  • Loading branch information
fearthecowboy authored and tbombach committed Jun 1, 2016
1 parent f980c82 commit 5ad191b
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 24 deletions.
2 changes: 2 additions & 0 deletions AutoRest/AutoRest.Core/AutoRest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion AutoRest/AutoRest.Core/Extensibility/ExtensionsLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public static CodeGenerator GetCodeGenerator(Settings settings)
/// <returns>Modeler specified in Settings.Modeler</returns>
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.");
Expand Down
11 changes: 11 additions & 0 deletions AutoRest/AutoRest.Core/Logging/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}

/// <summary>
/// An abstraction for the core to output text (ie not err,warning, or info)
/// </summary>
/// <param name="message"></param>
/// <param name="args"></param>
public static void WriteOutput(string message, params object[] args)
{
Console.ResetColor();
Console.WriteLine(message, args);
}

/// <summary>
/// Logs a message of severity LogEntrySeverity.Warning.
/// </summary>
Expand Down
11 changes: 10 additions & 1 deletion AutoRest/AutoRest.Core/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion AutoRest/AutoRest.Core/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,17 @@
<data name="InitializingCodeGenerator" xml:space="preserve">
<value>Initializing code generator.</value>
</data>
<data name="InitializingModeler" xml:space="preserve">
<value>Initializing modeler.</value>
</data>
<data name="InvalidIdentifierName" xml:space="preserve">
<value>Property name {0} cannot be used as an Identifier, as it contains only invalid characters.</value>
</data>
<data name="LanguageDoesNotSupportSingleFileGeneration" xml:space="preserve">
<value>'{0}' code generator does not support code generation to a single file.</value>
</data>
<data name="ModelerInitialized" xml:space="preserve">
<value>Initializing modeler.</value>
<value>Successfully initialized modeler {0} v {1}.</value>
</data>
<data name="NamespaceConflictReasonMessage" xml:space="preserve">
<value>{0} (already used in {1})</value>
Expand Down
6 changes: 6 additions & 0 deletions AutoRest/AutoRest.Core/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@ public string Header
[SettingsAlias("help")]
public bool ShowHelp { get; set; }

/// <summary>
/// If set to true, print out all messages.
/// </summary>
[SettingsAlias("verbose")]
public bool Verbose { get; set; }

/// <summary>
/// PackageName of then generated code package. Should be then names wanted for the package in then package manager.
/// </summary>
Expand Down
16 changes: 9 additions & 7 deletions AutoRest/AutoRest/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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();
}
}
Expand Down
27 changes: 14 additions & 13 deletions Documentation/cli.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#AutoRest Command Line Interface Documentation

##Syntax
`AutoRest.exe -Input <value> [-Namespace <value>] [-OutputDirectory <value>] [-CodeGenerator <value>] [-Modeler <value>] [-ClientName <value>] [-PayloadFlatteningThreshold <value>] [-Header <value>] [-AddCredentials <value>] [-OutputFileName <value>]`
`AutoRest.exe -Input <value> [-Verbose] [-Namespace <value>] [-OutputDirectory <value>] [-CodeGenerator <value>] [-Modeler <value>] [-ClientName <value>] [-PayloadFlatteningThreshold <value>] [-Header <value>] [-AddCredentials <value>] [-OutputFileName <value>]`

##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

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Tools/verify-settings.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down

0 comments on commit 5ad191b

Please sign in to comment.