I am new to Swift. I am using this library like this:
@main
final class Program: Options, ParsableCommand {
...
}
where
class Options {
@Option(name: [.customShort("w"), .long], help: "Image width (inches)")
var width: UInt = 24
@Option(name: [.customShort("h"), .long], help: "Image height (inches)")
var height: UInt = 24
}
when I run my program I get this error:
ArgumentParser/Option.swift:82: Fatal error:
Can't read a value from a parsable argument definition.
This error indicates that a property declared with an @Argument
,
@Option
, @Flag
, or @OptionGroup
property wrapper was neither
initialized to a value nor decoded from command-line arguments.
To get a valid value, either call one of the static parsing methods
(parse
, parseAsRoot
, or main
) or define an initializer that
initializes every property of your parsable type.
could anyone tell me what is the problem and how cn I fix it? thanks.