-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds the ability to insert an extra newline between large elements such as SECTOR when printing, which provides improved readability. Fixes #163
- Loading branch information
Showing
9 changed files
with
109 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System; | ||
|
||
namespace Compiler.Argument; | ||
|
||
[Flags] | ||
public enum Pretty | ||
{ | ||
NONE, | ||
PRETTY | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Compiler.Argument; | ||
|
||
namespace CompilerCli.Compiler; | ||
|
||
public class PrettyCompilerArgument : AbstractCompilerArgument | ||
{ | ||
public override void Parse(List<string> values, CompilerArguments compilerSettings) | ||
{ | ||
if (values.Count != 0) | ||
{ | ||
throw new ArgumentException("Pretty argument does not take any options"); | ||
} | ||
|
||
compilerSettings.Pretty = Pretty.PRETTY; | ||
} | ||
|
||
public override string GetSpecifier() | ||
{ | ||
return "--pretty"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
tests/CompilerCliTest/Compiler/PrettyCompilerArgumentTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Compiler.Argument; | ||
using CompilerCli.Compiler; | ||
using Xunit; | ||
|
||
namespace CompilerCliTest.Compiler; | ||
|
||
public class PrettyCompilerArgumentTest | ||
{ | ||
private CompilerArguments arguments; | ||
private PrettyCompilerArgument prettyCompilerArgument; | ||
|
||
public PrettyCompilerArgumentTest() | ||
{ | ||
arguments = new CompilerArguments(); | ||
prettyCompilerArgument = new PrettyCompilerArgument(); | ||
} | ||
|
||
[Fact] | ||
public void TestItSetsPrettyAsMode() | ||
{ | ||
prettyCompilerArgument.Parse(new List<string>(), arguments); | ||
Assert.Equal(Pretty.PRETTY, arguments.Pretty); | ||
} | ||
|
||
[Fact] | ||
public void TestItThrowsExceptionOnValues() | ||
{ | ||
Assert.Throws<ArgumentException>( | ||
() => prettyCompilerArgument.Parse(new List<string>(new[] { "a"}), arguments) | ||
); | ||
} | ||
|
||
[Fact] | ||
public void TestItReturnsASpecifier() | ||
{ | ||
Assert.Equal("--pretty", prettyCompilerArgument.GetSpecifier()); | ||
} | ||
} |