mirror of
https://github.com/AppleCommander/applesingle.git
synced 2024-06-01 05:41:31 +00:00
Tweaking to allow some useful filetype mnemonics.
This commit is contained in:
parent
4536b24763
commit
81656bc9b8
|
@ -75,7 +75,7 @@ Resource Fork: Not present
|
||||||
The `--fix-text` flag flips the high-bit and translates the newline character:
|
The `--fix-text` flag flips the high-bit and translates the newline character:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
$ echo "Hello World!" | asu create --name my-text-file --stdout --filetype 0x04 --stdin-fork=data --fix-text | hexdump -C
|
$ echo "Hello World!" | asu create --name my-text-file --stdout --filetype txt --stdin-fork=data --fix-text | hexdump -C
|
||||||
00000000 00 05 16 00 00 02 00 00 00 00 00 00 00 00 00 00 |................|
|
00000000 00 05 16 00 00 02 00 00 00 00 00 00 00 00 00 00 |................|
|
||||||
00000010 00 00 00 00 00 00 00 00 00 03 00 00 00 03 00 00 |................|
|
00000010 00 00 00 00 00 00 00 00 00 03 00 00 00 03 00 00 |................|
|
||||||
00000020 00 3e 00 00 00 0c 00 00 00 0b 00 00 00 4a 00 00 |.>...........J..|
|
00000020 00 3e 00 00 00 0c 00 00 00 0b 00 00 00 4a 00 00 |.>...........J..|
|
||||||
|
@ -89,7 +89,7 @@ $ echo "Hello World!" | asu create --name my-text-file --stdout --filetype 0x04
|
||||||
Without the `--fix-text` flag:
|
Without the `--fix-text` flag:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
$ echo "Hello World!" | asu create --name my-text-file --stdout --filetype 0x04 --stdin-fork=data | hexdump -C
|
$ echo "Hello World!" | asu create --name my-text-file --stdout --filetype txt --stdin-fork=data | hexdump -C
|
||||||
00000000 00 05 16 00 00 02 00 00 00 00 00 00 00 00 00 00 |................|
|
00000000 00 05 16 00 00 02 00 00 00 00 00 00 00 00 00 00 |................|
|
||||||
00000010 00 00 00 00 00 00 00 00 00 03 00 00 00 03 00 00 |................|
|
00000010 00 00 00 00 00 00 00 00 00 03 00 00 00 03 00 00 |................|
|
||||||
00000020 00 3e 00 00 00 0c 00 00 00 0b 00 00 00 4a 00 00 |.>...........J..|
|
00000020 00 3e 00 00 00 0c 00 00 00 0b 00 00 00 4a 00 00 |.>...........J..|
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class CreateCommand implements Callable<Void> {
|
||||||
@Option(names = "--access", description = "Set the ProDOS access flags", converter = IntegerTypeConverter.class)
|
@Option(names = "--access", description = "Set the ProDOS access flags", converter = IntegerTypeConverter.class)
|
||||||
private Integer access;
|
private Integer access;
|
||||||
|
|
||||||
@Option(names = "--filetype", description = "Set the ProDOS file type", converter = IntegerTypeConverter.class)
|
@Option(names = "--filetype", description = "Set the ProDOS file type (also accepts BIN/BAS/SYS)", converter = ProdosFileTypeConverter.class)
|
||||||
private Integer filetype;
|
private Integer filetype;
|
||||||
|
|
||||||
@Option(names = "--auxtype", description = "Set the ProDOS auxtype", converter = IntegerTypeConverter.class)
|
@Option(names = "--auxtype", description = "Set the ProDOS auxtype", converter = IntegerTypeConverter.class)
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
package io.github.applecommander.applesingle.tools.asu;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import picocli.CommandLine.ITypeConverter;
|
||||||
|
|
||||||
|
/** Add support for the more common ProDOS file type strings as well as integers. */
|
||||||
|
public class ProdosFileTypeConverter extends IntegerTypeConverter implements ITypeConverter<Integer> {
|
||||||
|
private final Map<String,String> fileTypes = new HashMap<String,String>() {
|
||||||
|
private static final long serialVersionUID = 1812781095833750521L;
|
||||||
|
{
|
||||||
|
put("TXT", "$04");
|
||||||
|
put("BIN", "$06");
|
||||||
|
put("INT", "$fa");
|
||||||
|
put("BAS", "$fc");
|
||||||
|
put("REL", "$fe");
|
||||||
|
put("SYS", "$ff");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer convert(String value) {
|
||||||
|
// If we find the string in our map, swap it for the correct hex string.
|
||||||
|
// Else just pass in the original value.
|
||||||
|
return super.convert(fileTypes.getOrDefault(value.toUpperCase(), value));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user