mirror of
https://github.com/jaquadro/NBTExplorer.git
synced 2025-01-10 01:46:24 +00:00
Add --delete operation
This commit is contained in:
parent
f28f96c27f
commit
4dfee8cfd6
4 changed files with 29 additions and 0 deletions
|
@ -11,6 +11,7 @@ namespace NBTUtil
|
|||
Print,
|
||||
PrintTree,
|
||||
SetValue,
|
||||
DeleteValue,
|
||||
SetList,
|
||||
Json,
|
||||
Help,
|
||||
|
@ -64,6 +65,7 @@ namespace NBTUtil
|
|||
break;
|
||||
}
|
||||
}},
|
||||
{ "delete", "Delete the NBT tag if found", v => Command = ConsoleCommand.DeleteValue },
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ namespace NBTUtil
|
|||
{
|
||||
private static readonly Dictionary<ConsoleCommand, ConsoleOperation> _commandTable = new Dictionary<ConsoleCommand, ConsoleOperation>() {
|
||||
{ ConsoleCommand.SetValue, new EditOperation() },
|
||||
{ ConsoleCommand.DeleteValue, new DeleteOperation() },
|
||||
{ ConsoleCommand.SetList, new SetListOperation() },
|
||||
{ ConsoleCommand.Print, new PrintOperation() },
|
||||
{ ConsoleCommand.PrintTree, new PrintTreeOperation() },
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
<Compile Include="ConsoleRunner.cs" />
|
||||
<Compile Include="NDesk\Options.cs" />
|
||||
<Compile Include="Ops\ConsoleOperation.cs" />
|
||||
<Compile Include="Ops\DeleteOperation.cs" />
|
||||
<Compile Include="Ops\EditOperation.cs" />
|
||||
<Compile Include="Ops\JsonOperation.cs" />
|
||||
<Compile Include="Ops\PrintOperation.cs" />
|
||||
|
|
25
NBTUtil/Ops/DeleteOperation.cs
Normal file
25
NBTUtil/Ops/DeleteOperation.cs
Normal file
|
@ -0,0 +1,25 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using NBTExplorer.Model;
|
||||
|
||||
namespace NBTUtil.Ops
|
||||
{
|
||||
class DeleteOperation : ConsoleOperation
|
||||
{
|
||||
public override bool OptionsValid (ConsoleOptions options)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool CanProcess (DataNode dataNode)
|
||||
{
|
||||
return (dataNode != null) && dataNode.CanDeleteNode && (dataNode.Root != dataNode);
|
||||
}
|
||||
|
||||
public override bool Process (DataNode dataNode, ConsoleOptions options)
|
||||
{
|
||||
return dataNode.DeleteNode();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue