Skip to content

Commit

Permalink
Don't panic when multiple files found, just show message to user
Browse files Browse the repository at this point in the history
  • Loading branch information
timabell committed Nov 20, 2024
1 parent a98162a commit 08f9863
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/CLI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ public int Run(string[] args)
Console.Error.WriteLine();
WriteUsage();
return 5;
} catch(MultipleSlnFilesFoundException ex) {
Console.Error.WriteLine(ex.Message);
return 6;
}

Console.Out.WriteLine("Sync completed.");
Expand Down
10 changes: 10 additions & 0 deletions tests/IntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,16 @@ public void FindsSlnFile()
ModifiedSln().Should().Be(expected);
}

[Fact]
public void FindsSlnFileInSameFolder()
{
File.WriteAllText(Path.Combine(_testFolder, "solution1.sln"), "blank");
File.WriteAllText(Path.Combine(_testFolder, "solution2.sln"), "blank");
_cli.Run(["some-file.txt"])
.Should().Be(6, because: "two solution files exist and arguments didn't specify which to use");
// todo: assert message written to stderr
}

private string ModifiedSln() => File.ReadAllText(Path.Combine(_testFolder, TargetSlnFile));

private void SetupFilesystem(IEnumerable<string> paths)
Expand Down

0 comments on commit 08f9863

Please sign in to comment.