I am trying to create a utility to create a DMG from a given number of files.
That DMG will contain a number of files and for each file I have a mandatory
name plus an optional position within the DMG window plus an optional type.
So the command line looks like the following:
createDMG [standard options] target [file specifications]
createDMG --verbose example.dmg \
bin/binary --position=20,20 \
README.pdf --position 20,80 \
/Applications --position 60,20 --type=link
In this example --verbose
is a "standard option".
As far as I know it is not possibility for the standard argument parser to parse the "file specifications". Am I correct or am I missing something here?
So I ended up by parsing the file specifications manually using custom code:
@Argument(
parsing: .unconditionalRemaining,
help: "Specify content in the form path [--position x y] [--type file|link]")
var args: [String]
And then in the run()
method I will parse args
manually.
One of the unwanted side-effects is that standard options like --verbose
must now precede the arguments.
Is there a better way?