blob: d88209ccd60e079e1e6ced27549c6a863152ba8d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
using CommandLineWrapper;
public class JVCSWorkspace
{
public string WorkspaceDirectory => _workspaceDirectory ?? Directory.GetCurrentDirectory();
private string? _workspaceDirectory;
public async Task InitializeAsync(string directory)
{
// If the specified directory does not exist, create it
if (!Directory.Exists(directory))
Directory.CreateDirectory(directory);
// Invoke command to get workspace directory
var result = await JVCSCommandInvoker.Invoke(Constants.CommandParameterGenerator.GetWorkspaceDirectory(), directory);
var currentWorkspace = result.StandardOutput;
// Check if the obtained workspace directory is valid (not empty and exists)
if (string.IsNullOrWhiteSpace(currentWorkspace) &&
Directory.Exists(currentWorkspace))
{
_workspaceDirectory = currentWorkspace;
}
else
{
// If the workspace is invalid, initialize a new workspace
await JVCSCommandInvoker.Invoke(Constants.CommandParameterGenerator.Initialize());
}
}
}
|