instancemetadata command stub

This commit is contained in:
Jindra Petřík
2024-01-21 16:09:30 +01:00
parent f56e918c3c
commit a34f9b1565
6 changed files with 307 additions and 1 deletions

View File

@@ -0,0 +1,38 @@
package com.jpexs.decompiler.flash.cli.commands;
import com.jpexs.decompiler.flash.cli.VersionProvider;
import com.jpexs.decompiler.flash.cli.commands.types.CompressionKind;
import com.jpexs.decompiler.flash.cli.commands.types.DeobfuscateLevel;
import com.jpexs.decompiler.flash.cli.commands.types.ImportObject;
import com.jpexs.decompiler.flash.cli.commands.types.ReplaceFormat;
import java.util.List;
import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;
import picocli.CommandLine.Parameters;
import picocli.CommandLine.ParentCommand;
import picocli.CommandLine.ArgGroup;
/**
*
* @author JPEXS
*/
@Command(
name = "instancemetadata",
mixinStandardHelpOptions = true,
versionProvider = VersionProvider.class,
header = "Instance metadata operations",
optionListHeading = "%n@|bold,underline Options|@:%n",
parameterListHeading = "%n@|bold,underline Parameters|@:%n",
synopsisHeading = "@|bold,underline Usage|@:",
sortSynopsis = false,
subcommands = {
InstanceMetadataGet.class,
InstanceMetadataSet.class,
InstanceMetadataRemove.class
}
)
public class InstanceMetadata {
}

View File

@@ -0,0 +1,81 @@
package com.jpexs.decompiler.flash.cli.commands;
import com.jpexs.decompiler.flash.cli.VersionProvider;
import com.jpexs.decompiler.flash.cli.commands.types.CompressionKind;
import com.jpexs.decompiler.flash.cli.commands.types.DeobfuscateLevel;
import com.jpexs.decompiler.flash.cli.commands.types.ImportObject;
import com.jpexs.decompiler.flash.cli.commands.types.InstanceMetadataFormat;
import com.jpexs.decompiler.flash.cli.commands.types.ReplaceFormat;
import java.util.List;
import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;
import picocli.CommandLine.Parameters;
import picocli.CommandLine.ParentCommand;
import picocli.CommandLine.ArgGroup;
/**
*
* @author JPEXS
*/
@Command(
name = "get",
mixinStandardHelpOptions = true,
versionProvider = VersionProvider.class,
header = "Get instance metadata",
optionListHeading = "%n@|bold,underline Options|@:%n",
parameterListHeading = "%n@|bold,underline Parameters|@:%n",
synopsisHeading = "@|bold,underline Usage|@:",
footerHeading = "%n@|bold,underline Examples|@:%n",
footer = {
"ffdec-cli instancemetadata get --instance=myitem --key=subkey1 input.swf",
"ffdec-cli instancemetadata get --instance=other --data-file=output.json input.swf",
"ffdec-cli instancemetadata get --instance=third --data-file=output.bin --output-format=raw input.swf",
},
sortSynopsis = false
)
public class InstanceMetadataGet implements Runnable {
@Option(
names = "--output-format",
description = "Format of output. @|bold Enum values|@: ${COMPLETION-CANDIDATES} Default is jslike."
)
InstanceMetadataFormat outputFormat = InstanceMetadataFormat.jslike;
@Option(
names = "--key",
paramLabel = "<key>",
description = "Name of subkey to display. When present, only value from subkey <key> is shown, whole object value otherwise."
)
String key;
@Option(
names = "--instance",
description = "Name of instance to fetch metadata from.",
required = true
)
String instance;
@Option(
names = "--data-file",
description = "File to write the data to. If ommited, stdout is used."
)
String outFile = null;
@Parameters(
index = "0",
paramLabel = "IN_FILE",
description = "Input file"
)
String inFile;
@Override
public void run() {
}
}

View File

@@ -0,0 +1,76 @@
package com.jpexs.decompiler.flash.cli.commands;
import com.jpexs.decompiler.flash.cli.VersionProvider;
import com.jpexs.decompiler.flash.cli.commands.types.CompressionKind;
import com.jpexs.decompiler.flash.cli.commands.types.DeobfuscateLevel;
import com.jpexs.decompiler.flash.cli.commands.types.ImportObject;
import com.jpexs.decompiler.flash.cli.commands.types.InstanceMetadataFormat;
import com.jpexs.decompiler.flash.cli.commands.types.ReplaceFormat;
import java.util.List;
import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;
import picocli.CommandLine.Parameters;
import picocli.CommandLine.ParentCommand;
import picocli.CommandLine.ArgGroup;
/**
*
* @author JPEXS
*/
@Command(
name = "remove",
mixinStandardHelpOptions = true,
versionProvider = VersionProvider.class,
header = "Remove instance metadata",
optionListHeading = "%n@|bold,underline Options|@:%n",
parameterListHeading = "%n@|bold,underline Parameters|@:%n",
synopsisHeading = "@|bold,underline Usage|@:",
footerHeading = "%n@|bold,underline Examples|@:%n",
footer = {
"ffdec-cli instancemetadata remove --instance=myitem --key=subkey1 input.swf",
"ffdec-cli instancemetadata remove --instance=other --out-file=output.swf input.swf",
},
sortSynopsis = false
)
public class InstanceMetadataRemove implements Runnable {
@Option(
names = "--key",
paramLabel = "<key>",
description = {
"Name of subkey to remove. When present, only the value from subkey <key> of the AMF object is removed.",
"Otherwise all metadata are removed from the instance."
}
)
String key;
@Option(
names = "--instance",
description = "Name of instance to remove data from.",
required = true
)
String instance;
@Option(
names = "--out-file",
description = "Where to save resulting file. If ommited, original SWF file is overwritten."
)
String outFile = null;
@Parameters(
index = "0",
paramLabel = "IN_FILE",
description = "Input file"
)
String inFile;
@Override
public void run() {
}
}

View File

@@ -0,0 +1,101 @@
package com.jpexs.decompiler.flash.cli.commands;
import com.jpexs.decompiler.flash.cli.VersionProvider;
import com.jpexs.decompiler.flash.cli.commands.types.CompressionKind;
import com.jpexs.decompiler.flash.cli.commands.types.DeobfuscateLevel;
import com.jpexs.decompiler.flash.cli.commands.types.ImportObject;
import com.jpexs.decompiler.flash.cli.commands.types.InstanceMetadataFormat;
import com.jpexs.decompiler.flash.cli.commands.types.ReplaceFormat;
import java.util.List;
import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;
import picocli.CommandLine.Parameters;
import picocli.CommandLine.ParentCommand;
import picocli.CommandLine.ArgGroup;
/**
*
* @author JPEXS
*/
@Command(
name = "set",
mixinStandardHelpOptions = true,
versionProvider = VersionProvider.class,
header = "Set instance metadata",
optionListHeading = "%n@|bold,underline Options|@:%n",
parameterListHeading = "%n@|bold,underline Parameters|@:%n",
synopsisHeading = "@|bold,underline Usage|@:",
footerHeading = "%n@|bold,underline Examples|@:%n",
footer = {
"ffdec-cli instancemetadata set --instance=myitem --key=subkey1 --value=5 --out-file=output.swf input.swf",
"ffdec-cli instancemetadata set --instance=other --data-file=input.bin --input-format=raw input.swf",
},
sortSynopsis = false
)
public class InstanceMetadataSet implements Runnable {
@Option(
names = "--input-format",
description = "Format of input data. @|bold Enum values|@: ${COMPLETION-CANDIDATES} Default is jslike."
)
InstanceMetadataFormat inputFormat = InstanceMetadataFormat.jslike;
@Option(
names = "--key",
paramLabel = "<key>",
description = {
"Name of subkey to use. When present, the value is set as object property with the <key> name.",
"Otherwise the value is set directly to the instance without any subkeys."
}
)
String key;
@ArgGroup(exclusive = true, multiplicity = "1")
ValueOrDataFile valueOrDataFile;
static class ValueOrDataFile {
@Option(
names = "--value",
description = "Value to set."
)
String value = null;
@Option(
names = "--data-file",
description = "Value to set from file."
)
String dataFile = null;
}
@Option(
names = "--instance",
description = "Name of instance to replace metadata in.",
required = true
)
String instance;
@Option(
names = "--out-file",
description = "Where to save resulting file. If ommited, original SWF file is overwritten."
)
String outFile = null;
@Parameters(
index = "0",
paramLabel = "IN_FILE",
description = "Input file"
)
String inFile;
@Override
public void run() {
}
}

View File

@@ -55,7 +55,8 @@ import picocli.CommandLine.ScopeType;
Import.class,
Deobfuscate.class,
EnableDebugging.class,
GenerateDoc.class
GenerateDoc.class,
InstanceMetadata.class
},
descriptionHeading = "%n@|bold,underline Description|@:%n",
optionListHeading = "%n@|bold,underline Options|@:%n",

View File

@@ -0,0 +1,9 @@
package com.jpexs.decompiler.flash.cli.commands.types;
/**
*
* @author JPEXS
*/
public enum InstanceMetadataFormat {
jslike, raw
}