From 17650f3f33a8c0f272c561c88ea9776f9c915cbd Mon Sep 17 00:00:00 2001 From: C272 Date: Wed, 18 Mar 2020 11:48:58 +0000 Subject: [PATCH] Add an output directory option. --- CLI/IroCLIOptions.cs | 12 ++++++++++ Program.cs | 21 +++++++++++++++++- Properties/AssemblyInfo.cs | 4 ++-- Templates/Resources.Designer.cs | 18 ++++++++++++--- Templates/Resources.resx | 6 +++++ .../Templates.Resources.Designer.cs.dll | Bin 4096 -> 4096 bytes .../iro4cli.Templates.Resources.resources | Bin 5276 -> 8404 bytes 7 files changed, 55 insertions(+), 6 deletions(-) diff --git a/CLI/IroCLIOptions.cs b/CLI/IroCLIOptions.cs index 313f4d0..430b0ef 100644 --- a/CLI/IroCLIOptions.cs +++ b/CLI/IroCLIOptions.cs @@ -18,6 +18,18 @@ public class IroCLIOptions [Value(0, Default = null, HelpText = "The Iro file to compile into other grammars.", Required = true)] public string File { get; set; } + /// + /// Displays the version header when isolated. + /// + [Option("version", Default = false, HelpText = "Shows the version information for this build of Iro.")] + public bool ShowVersionHeader { get; set; } + + /// + /// The output directory to generate into. + /// + [Option('o', "output", Default = null, HelpText = "Sets the folder to output results into.")] + public string OutputPath { get; set; } + /// /// Whether to generate textmate grammars or not. /// diff --git a/Program.cs b/Program.cs index cdfff82..af051a3 100644 --- a/Program.cs +++ b/Program.cs @@ -7,6 +7,8 @@ using iro4cli.Compile; using CommandLine; using iro4cli.CLI; +using iro4cli.Templates; +using System.Reflection; namespace iro4cli { @@ -14,6 +16,13 @@ class Program { static void Main(string[] args) { + //Args just "--version"? Display version. + if (args.Length == 1 && args[0] == "--version") + { + PrintVersionInfo(); + return; + } + //Disable help writer. var parser = new Parser(config => config.HelpWriter = null); @@ -23,6 +32,14 @@ static void Main(string[] args) .WithNotParsed(HandleParseError); } + //Prints version info and a nice little text banner to console. + private static void PrintVersionInfo() + { + Console.WriteLine(Resources.asciiArt); + Console.WriteLine(" v" + Assembly.GetExecutingAssembly().GetName().Version.ToString()); + Console.WriteLine("\niro4cli (c) C272, 2020. Iro (c) Chris Ainsley.\n"); + } + //Called when an error has occured parsing the command line options. private static void HandleParseError(IEnumerable errors) { @@ -63,12 +80,14 @@ private static void Run(IroCLIOptions opts) var compileResults = Compiler.Compile(vars, targets.ToArray()); foreach (var result in compileResults) { + //Yay, successfully generated! Console.Write("Successfully generated for target '"); Console.ForegroundColor = ConsoleColor.Green; Console.Write(result.Target.ToString().Replace("Target.", "")); Console.ResetColor(); Console.Write("'.\r\n"); + //Try to write the file now (with the right file extension). string ext = ".unknown"; switch (result.Target) { @@ -98,7 +117,7 @@ private static void Run(IroCLIOptions opts) } //todo: add a directory value - WriteFile(result.GeneratedFile, ((IroValue)vars["name"]).Value, ext, null); + WriteFile(result.GeneratedFile, ((IroValue)vars["name"]).Value, ext, opts.OutputPath); } } diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 1887096..5e30dfe 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -10,7 +10,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("iro4cli")] -[assembly: AssemblyCopyright("Copyright © 2020")] +[assembly: AssemblyCopyright("Copyright © C272 2020")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Templates/Resources.Designer.cs b/Templates/Resources.Designer.cs index 1fd8f25..302b9f8 100644 --- a/Templates/Resources.Designer.cs +++ b/Templates/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace iro4cli.Templates { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { @@ -72,6 +72,18 @@ internal static string _vscodeignore { } } + /// + /// Looks up a localized string similar to _ ___ __ _ _ ____ _ + ///| | _ \/__\ | || | / _/ | | | + ///| | v / \/ | `._ _| | \_| |_| | + ///|_|_|_\\__/ |_| \__/___|_|. + /// + internal static string asciiArt { + get { + return ResourceManager.GetString("asciiArt", resourceCulture); + } + } + /// /// Looks up a localized string similar to # Change Log ///*Generated by Iro.* @@ -134,7 +146,7 @@ internal static string linuxDebug_sh { /// ///\!\[feature X\]\(images/feature-x.png\) /// - ///> Tip: Many popular extensio [rest of string was truncated]";. + ///> Tip: Many popu [rest of string was truncated]";. /// internal static string README_md { get { @@ -150,7 +162,7 @@ internal static string README_md { ///* This folder contains all of the files necessary for your extension. ///* `package.json` - this is the manifest file in which you declare your language support and define the location of the grammar file that has been copied into your extension. ///* `syntaxes/test.tmlanguage.txt` - this is the Text mate grammar file that is used for tokenization. - ///* `language-configuration.json` - this is the language configuration, defining the tokens that are used f [rest of string was truncated]";. + ///* `language-configuration.json` - this is the language configuration, defining the tokens that are [rest of string was truncated]";. /// internal static string vsc_extension_quickstart_md { get { diff --git a/Templates/Resources.resx b/Templates/Resources.resx index f99a737..e977b4d 100644 --- a/Templates/Resources.resx +++ b/Templates/Resources.resx @@ -259,4 +259,10 @@ Added features X, Y, and Z. .gitignore vsc-extension-quickstart.md + + _ ___ __ _ _ ____ _ +| | _ \/__\ | || | / _/ | | | +| | v / \/ | `._ _| | \_| |_| | +|_|_|_\\__/ |_| \__/___|_| + \ No newline at end of file diff --git a/obj/Debug/TempPE/Templates.Resources.Designer.cs.dll b/obj/Debug/TempPE/Templates.Resources.Designer.cs.dll index 0a548ff4c98c8d45a154afc1a31584d90ef27a3b..252c0d4cb370c2e21d72e3f2138f80186cacd86f 100644 GIT binary patch delta 433 zcmXYtO(=v>6o%jP{TX9ue*8pe#wePFCM8A|MubpGLn-;4#`vq5Z#GJd-IP&2$Hq=} zmKsu4wn}!g5f-y1D=d_Ir|+EZd+zggyS<&PKkGlrscXfQbf;x+HS(YU!Cjz71=__4 zPG!=`t%NDRUNC@05?*WyJ7s`dc){V==%AQ+j%eNF;*?gWI|Wzpp|(!V{HtwGRH~~Y zQFTDrU`GIw`fM6dB(2zVLXz?}`ARRZZ0ao03t#GE)WCoGoZ?Y=+E~&RxKP74#z5iQ z@TxV7=5jI_O=pmZXXc}(8Q)ym*k-SD#_d^ziDe{3N0CN`6V4m=tugC6|2P}XJ@vo+ z41EPSTu}^lb%bRD8i~vf5}`_UW$#$RqrCgAKrP)BVyUC)Y>>0!^B9Aylq!CXDYVU_{#j(* zTiem@y?K_5ti-%!mS&e;h0U^O?}DWw#(4XVJ&f3OCb$rSW8!E8=u0^Qh(xT)s{p1U zgvkM`wC3F4!k`tpqEwJFDP>KQ3>8e8B?3iIH%)H7o_nS3Itz{^uR-7yUb<0A=p|q=ZltPi2*{JLWi!C2`<<7d=6@V_v#r3PojM3{)3H??o$i3Bx}xfU5AV=F$8M> mIIBaJmQ311%)xL%9>9@;{gXA|O^GA*9X~nXk}#$r|Ic3>wtH;= delta 161 zcmccOI7f5BLJxKZ2ncX=0iplab0=gy4p|qr*Y|yAcd_KjC6lCc4sQ+kDDxsb7^u<& zi1UEB7l>tn_yiDxz{QCl!_38U7!nyuf%3@=84U3ZSq#Mt`9R(UP6h_49EMCFvy`EN r!G$4}AqmJz2P!EBDm0ipnbC?dWb!#i8Kxydo8K^A=G^SX^NRxjBCsuN