|
1 | 1 | using GitContentSearch.Helpers; |
2 | | -using System; |
| 2 | +using System.IO; |
3 | 3 |
|
4 | 4 | namespace GitContentSearch |
5 | 5 | { |
@@ -41,15 +41,30 @@ static void Main(string[] args) |
41 | 41 | } |
42 | 42 | } |
43 | 43 |
|
| 44 | + string logAndTempFileDirectory = logDirectory ?? string.Empty; |
| 45 | + if (string.IsNullOrEmpty(logAndTempFileDirectory)) |
| 46 | + { |
| 47 | + string tempPath = Path.GetTempPath(); |
| 48 | + logAndTempFileDirectory = Path.Combine(tempPath, "GitContentSearch"); |
| 49 | + |
| 50 | + if (!Directory.Exists(logAndTempFileDirectory)) |
| 51 | + { |
| 52 | + Directory.CreateDirectory(logAndTempFileDirectory); |
| 53 | + } |
| 54 | + } |
| 55 | + |
| 56 | + Console.WriteLine("Starting GitContentSearch..."); |
| 57 | + Console.WriteLine($"Logs and temporary files will be created in: {logAndTempFileDirectory}"); |
| 58 | + |
44 | 59 | var logWriter = new CompositeTextWriter( |
45 | 60 | Console.Out, |
46 | | - new StreamWriter(Path.Combine(logDirectory ?? Directory.GetCurrentDirectory(), "search_log.txt"), append: true) |
| 61 | + new StreamWriter(Path.Combine(logAndTempFileDirectory, "search_log.txt"), append: true) |
47 | 62 | ); |
48 | 63 |
|
49 | 64 | var processWrapper = new ProcessWrapper(); |
50 | 65 | var gitHelper = new GitHelper(processWrapper, workingDirectory); |
51 | 66 | var fileSearcher = new FileSearcher(); |
52 | | - var fileManager = new FileManager(logDirectory); |
| 67 | + var fileManager = new FileManager(logAndTempFileDirectory); |
53 | 68 | var gitContentSearcher = new GitContentSearcher(gitHelper, fileSearcher, fileManager, logWriter); |
54 | 69 | gitContentSearcher.SearchContent(filePath, searchString, earliestCommit, latestCommit); |
55 | 70 | } |
|
0 commit comments