Skip to content

Commit

Permalink
Add an output directory option.
Browse files Browse the repository at this point in the history
  • Loading branch information
c272 committed Mar 18, 2020
1 parent 1995462 commit 17650f3
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 6 deletions.
12 changes: 12 additions & 0 deletions CLI/IroCLIOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

/// <summary>
/// Displays the version header when isolated.
/// </summary>
[Option("version", Default = false, HelpText = "Shows the version information for this build of Iro.")]
public bool ShowVersionHeader { get; set; }

/// <summary>
/// The output directory to generate into.
/// </summary>
[Option('o', "output", Default = null, HelpText = "Sets the folder to output results into.")]
public string OutputPath { get; set; }

/// <summary>
/// Whether to generate textmate grammars or not.
/// </summary>
Expand Down
21 changes: 20 additions & 1 deletion Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,22 @@
using iro4cli.Compile;
using CommandLine;
using iro4cli.CLI;
using iro4cli.Templates;
using System.Reflection;

namespace iro4cli
{
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);

Expand All @@ -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<CommandLine.Error> errors)
{
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);
}
}

Expand Down
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("iro4cli")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyCopyright("Copyright © C272 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -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")]
18 changes: 15 additions & 3 deletions Templates/Resources.Designer.cs

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

6 changes: 6 additions & 0 deletions Templates/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -259,4 +259,10 @@ Added features X, Y, and Z.
.gitignore
vsc-extension-quickstart.md</value>
</data>
<data name="asciiArt" xml:space="preserve">
<value>_ ___ __ _ _ ____ _
| | _ \/__\ | || | / _/ | | |
| | v / \/ | `._ _| | \_| |_| |
|_|_|_\\__/ |_| \__/___|_|</value>
</data>
</root>
Binary file modified obj/Debug/TempPE/Templates.Resources.Designer.cs.dll
Binary file not shown.
Binary file modified obj/Debug/iro4cli.Templates.Resources.resources
Binary file not shown.

0 comments on commit 17650f3

Please sign in to comment.