fadden / CiderPress2

Tool for working with Apple II and vintage Mac disk images and file archives.
https://ciderpress2.com/
Apache License 2.0
50 stars 7 forks source link

Change order of arguments to set-attr #30

Closed fadden closed 2 months ago

fadden commented 2 months ago

The current definition of the set-attr command is: set-attr [options] <ext-archive> <file-in-archive> [attrs...]

The optional attrs argument is a space-separated list of attributes, e.g. type=BIN aux=0x2000. If the attribute list is omitted, the command behaves like get-attr instead (there is no get-attr command). There are a couple of problems with this:

Furthermore, the current argument order prevents the command from allowing the user to mark a big pile of files read-only with a statement like cp2 set-attr mydisk.po locked file1 file2 file3.

Four changes should be made:

  1. The order of arguments should be changed, so that the attributes come before the filename.
  2. The attributes should be a comma-separated list, rather than space-separated. This is for convenience when setting multiple attributes.
  3. The command should take multiple filenames, with the usual wildcard support.
  4. The no-attribute form of the command no longer makes sense, so we need a get-attr command.

Switching from space-separated to comma-separated shouldn't cause problems. The only opportunity for commas to appear naturally is in the Mac creator/file type strings, but that should be rare, and those allow hex digits to be provided.

This should improve the function of the command, and allow the behavior requested in issue #27.

The command should only descend into subdirectories if --recurse is given on the command line. It's reasonable to change the attributes of a directory.

The get-attr command is fundamentally a single-file command. The argument order should be the same as the old set-attr, so that we can take an attribute name as an optional argument: get-attr [options] <ext-archive> <file-in-archive> [attr]

The idea is that get-attr file dumps the full list of attributes as human-readable name/value pairs, while e.g. get-attr file type just prints the value in a machine-readable sort of way. This could be useful for shell scripts.

Sample of current output:

Attributes for 'Pics.3200/ROSE.3200':
  File Type   : PNT $c0
  Aux Type    : $8005
  HFS Type    : '␀␀␀␀' $00000000
  HFS Creator : '␀␀␀␀' $00000000
  Access      : $e3 [dnbwr]
  Create Date : 24-Sep-1991 01:12:00
  Mod Date    : 24-Sep-1991 01:12:00
  Comment     : (none)
fadden commented 2 months ago

Available in https://github.com/fadden/CiderPress2/releases/tag/v1.0.4-dev2