2021-09-27 12:42:46 +00:00
|
|
|
using System.CommandLine;
|
|
|
|
using System.CommandLine.Invocation;
|
|
|
|
using System.Threading;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using Wabbajack.Paths;
|
|
|
|
using Wabbajack.VFS;
|
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
namespace Wabbajack.CLI.Verbs;
|
|
|
|
|
|
|
|
public class VFSIndexFolder : IVerb
|
2021-09-27 12:42:46 +00:00
|
|
|
{
|
2021-10-23 16:51:17 +00:00
|
|
|
private readonly Context _context;
|
2021-09-27 12:42:46 +00:00
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
public VFSIndexFolder(Context context)
|
|
|
|
{
|
|
|
|
_context = context;
|
|
|
|
}
|
2021-09-27 12:42:46 +00:00
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
public Command MakeCommand()
|
|
|
|
{
|
|
|
|
var command = new Command("vfs-index");
|
|
|
|
command.Add(new Option<AbsolutePath>(new[] {"-f", "--folder"}, "Folder to index"));
|
|
|
|
command.Description = "Index and cache the contents of a folder";
|
2021-09-27 12:42:46 +00:00
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
command.Handler = CommandHandler.Create(Run);
|
|
|
|
return command;
|
|
|
|
}
|
2021-09-27 12:42:46 +00:00
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
public async Task<int> Run(AbsolutePath folder)
|
|
|
|
{
|
|
|
|
await _context.AddRoot(folder, CancellationToken.None);
|
|
|
|
return 0;
|
2021-09-27 12:42:46 +00:00
|
|
|
}
|
|
|
|
}
|