Skip to content

Commit 2d2fe61

Browse files
committed
fix saving into the same file
1 parent 2bb8986 commit 2d2fe61

File tree

2 files changed

+6
-19
lines changed

2 files changed

+6
-19
lines changed

pbn/PbnApplication.cs

+3-16
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,14 @@ public class Application
2727
/// </summary>
2828
public const string Version = "0.1.0";
2929

30-
static Application()
31-
{
32-
if (Instance != null)
33-
throw new InvalidOperationException("PbnApplication already exists");
34-
Instance = new Application();
35-
}
3630

37-
private Application()
31+
public Application()
3832
{
3933
tagFactory = TagFactory.MakeDefault();
4034
parser = new PbnParser(PbnParser.RecoveryMode.Strict, tagFactory);
4135
boardManipulator = new PbnBoardManipulator();
4236
}
43-
44-
/// <summary>
45-
/// Singleton instance.
46-
/// </summary>
47-
public static Application Instance { get; }
48-
37+
4938
/// <summary>
5039
/// True if the application was started with the verbose flag.
5140
/// </summary>
@@ -75,13 +64,11 @@ public void Run(Options options)
7564

7665
private void HandleFile(string filename, Options options)
7766
{
78-
using var inputFile = new StreamReader(filename);
79-
80-
8167
PbnFile file;
8268

8369
try
8470
{
71+
using var inputFile = new StreamReader(filename);
8572
file = parser.Parse(inputFile);
8673
}
8774
catch (Exception e)

pbn/Program.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ private static void Main(string[] args)
1111
Parser.Default.ParseArguments<Options>(args)
1212
.WithParsed(RunOptions)
1313
.WithNotParsed(HandleParseError);
14-
15-
14+
1615
}
1716

1817
private static void RunOptions(Options opts)
1918
{
2019
try
2120
{
22-
Application.Instance.Run(opts);
21+
var app = new Application();
22+
app.Run(opts);
2323
} catch (Exception e)
2424
{
2525
Console.Error.WriteLine("Error: " + e.Message);

0 commit comments

Comments
 (0)