Compare commits
No commits in common. "5e33a2bccfab3d36c86677a727f9f99d2d9bc9d7" and "031dbf06c95a3a0f6f273f05085d8aeac82e6a63" have entirely different histories.
5e33a2bccf
...
031dbf06c9
7 changed files with 152 additions and 270 deletions
|
|
@ -4,11 +4,13 @@ version = "0.0.1"
|
||||||
authors = ["Thomas A. Christensen II <25492070+MillironX@users.noreply.github.com> and contributors"]
|
authors = ["Thomas A. Christensen II <25492070+MillironX@users.noreply.github.com> and contributors"]
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
OptParse = "1244ff17-1aa7-4121-9347-f4ead108e58f"
|
ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63"
|
||||||
|
FilePathsBase = "48062228-2e41-5def-b9a4-89aafe57970f"
|
||||||
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
|
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
|
||||||
|
|
||||||
[compat]
|
[compat]
|
||||||
OptParse = "0.4.3"
|
ArgParse = "1.2.0"
|
||||||
|
FilePathsBase = "0.9.24"
|
||||||
UUIDs = "1.11.0"
|
UUIDs = "1.11.0"
|
||||||
julia = "1.12"
|
julia = "1.12"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,4 @@
|
||||||
# CualerID
|
# CualerID
|
||||||
|
|
||||||
[](https://millironx.com/CualerID.jl/stable)
|
|
||||||
[](https://millironx.com/CualerID.jl/dev)
|
|
||||||
[](https://woodpecker.millironx.com/repos/31)
|
|
||||||
[](https://github.com/invenia/BlueStyle)
|
[](https://github.com/invenia/BlueStyle)
|
||||||
[](https://github.com/JuliaTesting/Aqua.jl)
|
[](https://github.com/JuliaTesting/Aqua.jl)
|
||||||
|
|
|
||||||
|
|
@ -27,12 +27,11 @@ const BASE30_ALPHABET = UInt8.([
|
||||||
])
|
])
|
||||||
|
|
||||||
"""
|
"""
|
||||||
base30encode(v::Integer; pad::Integer=1)
|
base30encode(v::Integer)
|
||||||
base30encode(v::UUID; pad::Integer=1)
|
base30encode(v::UUID)
|
||||||
|
|
||||||
Creates a base30 representation of `v` padded out to `pad` digits. If `v` is a
|
Creates a base30 representation of `v`. If `v` is a `UUID`, then the `UInt128`
|
||||||
`UUID`, then the `UInt128` value of the `UUID` is passed directly into the
|
value of the `UUID` is passed directly into the method.
|
||||||
method.
|
|
||||||
|
|
||||||
# Examples
|
# Examples
|
||||||
|
|
||||||
|
|
@ -46,12 +45,10 @@ julia> using UUIDs; base30encode(uuid1())
|
||||||
"7ZK00JECBDF2H7GNBXN59C6S9S"
|
"7ZK00JECBDF2H7GNBXN59C6S9S"
|
||||||
```
|
```
|
||||||
"""
|
"""
|
||||||
function base30encode(v::Integer; pad::Integer = 1)
|
function base30encode(v::Integer)
|
||||||
return String([
|
return String([BASE30_ALPHABET[i] for i in reverse(digits(v; base = 30) .+ 1)])
|
||||||
BASE30_ALPHABET[i] for i in reverse(digits(v; base = 30, pad = pad) .+ 1)
|
|
||||||
])
|
|
||||||
end #function
|
end #function
|
||||||
|
|
||||||
function base30encode(v::UUID; pad::Integer = 1)
|
function base30encode(v::UUID)
|
||||||
return base30encode(v.value; pad = pad)
|
return base30encode(v.value)
|
||||||
end #function
|
end #function
|
||||||
|
|
|
||||||
249
src/CualerID.jl
249
src/CualerID.jl
|
|
@ -1,143 +1,174 @@
|
||||||
module CualerID
|
module CualerID
|
||||||
|
|
||||||
using OptParse:
|
using ArgParse: ArgParse, ArgParseSettings, parse_args, parse_item, @add_arg_table!
|
||||||
@parser,
|
using FilePathsBase: AbstractPath, Path, exists, isfile
|
||||||
OptParse,
|
using UUIDs: UUID
|
||||||
arg,
|
|
||||||
command,
|
|
||||||
default,
|
|
||||||
flag,
|
|
||||||
flt,
|
|
||||||
lift,
|
|
||||||
option,
|
|
||||||
or,
|
|
||||||
path,
|
|
||||||
runparse,
|
|
||||||
str,
|
|
||||||
u64
|
|
||||||
using UUIDs: UUID, uuid4
|
|
||||||
|
|
||||||
include("Base30.jl")
|
include("Base30.jl")
|
||||||
include("ResultCodeOption.jl")
|
include("ResultCodeOption.jl")
|
||||||
include("ResultCodeOptionValueParser.jl")
|
|
||||||
include("Minting.jl")
|
include("Minting.jl")
|
||||||
|
|
||||||
export ResultCode
|
export ResultCode
|
||||||
export ResultCodeOption
|
export ResultCodeOption
|
||||||
export base30encode
|
export base30encode
|
||||||
export cualer_id
|
|
||||||
export has_duplicate
|
export has_duplicate
|
||||||
export has_fixed
|
export has_fixed
|
||||||
export has_not_fixable
|
export has_not_fixable
|
||||||
export has_valid
|
export has_valid
|
||||||
export mint_ids!
|
|
||||||
|
|
||||||
@parser struct CreateIDs
|
function _create_arg_table()
|
||||||
@description "Create a set of new CualerIDs"
|
s = ArgParseSettings(autofix_names = true)
|
||||||
|
|
||||||
"The length of the printed sample ids"
|
#! format: off
|
||||||
length = option("-l", "--length", u64("LENGTH")) |> default(0x05)
|
@add_arg_table! s begin
|
||||||
|
"create"
|
||||||
|
help = "Create CualerID sample ids or barcode labels"
|
||||||
|
action = :command
|
||||||
|
"fix"
|
||||||
|
help = "Compare a set of possibly invalid IDs against a correct set of IDs to identify errors in the IDs"
|
||||||
|
action = :command
|
||||||
|
"convert"
|
||||||
|
help = "Convert CualID sample ids to CualerID sample ids or vice-versa"
|
||||||
|
action = :command
|
||||||
|
end #add_arg_table
|
||||||
|
|
||||||
"The fraction of ids which must be dissimilar"
|
@add_arg_table! s["create"] begin
|
||||||
fail_threshold =
|
"ids"
|
||||||
option("-f", "--fail-threshold", flt("THRESHOLD"; min = 0.0, max = 1.0)) |>
|
help = "Generate sample ids"
|
||||||
default(0.99)
|
action = :command
|
||||||
|
"labels"
|
||||||
|
help = "Generate a pdf of barcodes (NOT YET IMPLEMENTED)"
|
||||||
|
action = :command
|
||||||
|
end #add_arg_table
|
||||||
|
|
||||||
"The number of sample ids to print"
|
@add_arg_table! s["create"]["ids"] begin
|
||||||
number_of_ids = arg(u64("NUMBER"; min = 0x01))
|
"--length", "-l"
|
||||||
end #struct
|
help = "The length of the printed sample ids"
|
||||||
|
arg_type = UInt64
|
||||||
@parser struct CreateLabels
|
default = UInt64(5)
|
||||||
@description "Create printable labels from CualerIDs"
|
"--fail-threshold", "-f"
|
||||||
|
help = "NOT IMPLEMENTED: The rate at which similar ids will fail the process"
|
||||||
|
arg_type = Float64
|
||||||
|
range_tester = x -> x >= 0 && x <= 1.0
|
||||||
|
default = 0.99
|
||||||
|
"number_of_ids"
|
||||||
|
help = "The number of sample ids to print"
|
||||||
|
arg_type = UInt64
|
||||||
|
range_tester = x -> x >= 1
|
||||||
|
required = true
|
||||||
|
end #add_arg_table
|
||||||
|
|
||||||
|
@add_arg_table! s["fix"] begin
|
||||||
|
"--correct-ids"
|
||||||
|
help = "Path to the list of correct ids"
|
||||||
|
arg_type = AbstractPath
|
||||||
|
range_tester = x -> exists(x) && isfile(x)
|
||||||
|
required = true
|
||||||
|
"--show", "-s"
|
||||||
|
help = """
|
||||||
|
Which types of fixes should be printed to output. Can be a
|
||||||
|
combination of D for duplicate, F for fixed, N for not fixable,
|
||||||
|
and V for valid.
|
||||||
"""
|
"""
|
||||||
The input file containing sample ids. The input sample ids can be in either CualID or
|
arg_type = ResultCodeOption
|
||||||
CualerID format, but the output labels will always be in CualerID format.
|
default = ResultCodeOption("DFN")
|
||||||
"""
|
"--all", "-a"
|
||||||
input = arg(path("SAMPLE_IDS"))
|
help = "Show all ids regardless of fixed status"
|
||||||
|
action = :store_true
|
||||||
|
"ids_to_be_corrected"
|
||||||
|
help = "File containing CualerIDs that need correction"
|
||||||
|
arg_type = AbstractPath
|
||||||
|
range_tester = x -> exists(x) && isfile(x)
|
||||||
|
required = true
|
||||||
|
end #add_arg_table
|
||||||
|
|
||||||
"Path to output file"
|
@add_arg_table! s["convert"] begin
|
||||||
output_pdf = option("-o", "--output-pdf", path("OUTPUT_FILE"))
|
"--length", "-l"
|
||||||
|
help = "The length of the printed sample ids"
|
||||||
|
arg_type = UInt64
|
||||||
|
default = UInt64(5)
|
||||||
|
"--fail-threshold", "-f"
|
||||||
|
help = "NOT IMPLEMENTED: The rate at which similar ids will fail the process"
|
||||||
|
arg_type = Float64
|
||||||
|
range_tester = x -> x >= 0 && x <= 1.0
|
||||||
|
default = 0.99
|
||||||
|
"--to-cual-id"
|
||||||
|
help = "Convert from CualerID to CualID"
|
||||||
|
action = :store_true
|
||||||
|
"ids_to_be_converted"
|
||||||
|
help = "TSV file containing CualIDs or CualerIDs to be converted"
|
||||||
|
arg_type = AbstractPath
|
||||||
|
range_tester = x -> exists(x) && isfile(x)
|
||||||
|
required = true
|
||||||
|
end #@add_arg_table!
|
||||||
|
|
||||||
"Do not print sample ids on the labels (i.e. barcodes only)"
|
#! format: on
|
||||||
suppress_ids = flag("--suppress-ids")
|
|
||||||
|
|
||||||
"""
|
return s
|
||||||
Barcode type selector. This option is present to maintain cli compatibility with
|
|
||||||
cual-id, however it was never implemented in the original program, and as
|
|
||||||
such is not implemented, but instead silently ignored by cualer-id.
|
|
||||||
"""
|
|
||||||
barcode = option("--barcode", str("DUMMY")) |> default("DUMMY")
|
|
||||||
end #struct
|
|
||||||
|
|
||||||
@parser struct Fix
|
|
||||||
@description "Fix typos in lists of CualerIDs"
|
|
||||||
|
|
||||||
"Path to the list of correct ids"
|
|
||||||
correct_ids = option("--correct-ids", path("CORRECT_IDS"))
|
|
||||||
|
|
||||||
"""
|
|
||||||
Which types of fixes should be printed to output. Can be a combination of D
|
|
||||||
for duplicate, F for fixed, N for not fixable, and V for valid.
|
|
||||||
"""
|
|
||||||
show =
|
|
||||||
option("-s", "--show", result_code_option("FIXES")) |>
|
|
||||||
default(ResultCodeOption("DFN"))
|
|
||||||
|
|
||||||
# TODO: Implement the --all switch as an exclusive that returns
|
|
||||||
# a ResultCodeOption("DFNV")
|
|
||||||
|
|
||||||
"File containing CualerIDs that need correction"
|
|
||||||
ids_to_be_corrected = arg(path("FILE"))
|
|
||||||
end #struct
|
|
||||||
|
|
||||||
@parser struct Convert
|
|
||||||
@description "Convert existing CualIDs to CualerIDs (and vice-versa)"
|
|
||||||
|
|
||||||
"The length of the printed sample ids"
|
|
||||||
length = option("-l", "--length", u64("LENGTH")) |> default(0x05)
|
|
||||||
|
|
||||||
"The fraction of ids which must be dissimilar"
|
|
||||||
fail_threshold =
|
|
||||||
option("-f", "--fail-threshold", flt("THRESHOLD"; min = 0.0, max = 1.0)) |>
|
|
||||||
default(0.99)
|
|
||||||
|
|
||||||
"Convert from CualerID to CualID"
|
|
||||||
to_cual_id = flag("--to-cual-id")
|
|
||||||
|
|
||||||
"TSV file containing CualIDs or CualerIDs to be converted"
|
|
||||||
ids_to_be_converted = arg(path("SAMPLE_IDS"))
|
|
||||||
end #struct
|
|
||||||
|
|
||||||
const CLI = or(
|
|
||||||
command(
|
|
||||||
"create",
|
|
||||||
or(command("ids", lift(CreateIDs)), command("labels", lift(CreateLabels))),
|
|
||||||
),
|
|
||||||
command("fix", lift(Fix)),
|
|
||||||
command("convert", lift(Convert)),
|
|
||||||
)
|
|
||||||
|
|
||||||
function (@main)(args)
|
|
||||||
opts = runparse(CLI, args; progname="cualer-id")
|
|
||||||
|
|
||||||
# Exit early in case of a help command
|
|
||||||
isnothing(opts) && return 0
|
|
||||||
|
|
||||||
return _main(opts)
|
|
||||||
end #function
|
end #function
|
||||||
|
|
||||||
function _main(opts::CreateIDs)
|
const ARG_PARSE_TABLE = _create_arg_table()
|
||||||
ids = mint_ids!(opts.number_of_ids, opts.length, opts.fail_threshold)
|
|
||||||
|
|
||||||
foreach(i -> println(i, '\t', cualer_id(i; length = opts.length)), ids)
|
function _create(parsed_args::Dict{Symbol,Any})
|
||||||
|
if parsed_args[:_COMMAND_] == :ids
|
||||||
|
_create_ids(parsed_args[:ids])
|
||||||
|
elseif parsed_args[:_COMMAND_] == :labels
|
||||||
|
_create_labels(parsed_args[:labels])
|
||||||
|
end #if
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
end #function
|
end #function
|
||||||
|
|
||||||
function _main(opts)
|
function _create_ids(parsed_args::Dict{Symbol,Any})
|
||||||
@show opts
|
println("COMMAND:\tcreate ids")
|
||||||
@assert false
|
for (key, val) in parsed_args
|
||||||
|
println("\t$key:\t$val")
|
||||||
|
end #function
|
||||||
|
|
||||||
|
return 0
|
||||||
|
end #function
|
||||||
|
|
||||||
|
function _create_labels(parsed_args::Dict{Symbol,Any})
|
||||||
|
println("COMMAND:\tcreate labels")
|
||||||
|
for (key, val) in parsed_args
|
||||||
|
println("\t$key:\t$val")
|
||||||
|
end #function
|
||||||
|
|
||||||
|
return 0
|
||||||
|
end #function
|
||||||
|
|
||||||
|
function _fix(parsed_args::Dict{Symbol,Any})
|
||||||
|
println("COMMAND:\tfix")
|
||||||
|
for (key, val) in parsed_args
|
||||||
|
println("\t$key:\t$val")
|
||||||
|
end #function
|
||||||
|
|
||||||
|
return 0
|
||||||
|
end #function
|
||||||
|
|
||||||
|
function _convert(parsed_args::Dict{Symbol,Any})
|
||||||
|
println("COMMAND:\tconvert")
|
||||||
|
for (key, val) in parsed_args
|
||||||
|
println("\t$key:\t$val")
|
||||||
|
end #function
|
||||||
|
|
||||||
|
return 0
|
||||||
|
end #function
|
||||||
|
|
||||||
|
|
||||||
|
function (@main)()
|
||||||
|
parsed_args = parse_args(ARG_PARSE_TABLE; as_symbols = true)
|
||||||
|
|
||||||
|
if parsed_args[:_COMMAND_] == :create
|
||||||
|
_create(parsed_args[:create])
|
||||||
|
elseif parsed_args[:_COMMAND_] == :fix
|
||||||
|
_fix(parsed_args[:fix])
|
||||||
|
elseif parsed_args[:_COMMAND_] == :convert
|
||||||
|
_convert(parsed_args[:convert])
|
||||||
|
end #if
|
||||||
|
|
||||||
|
return 0
|
||||||
end #function
|
end #function
|
||||||
|
|
||||||
end #module
|
end #module
|
||||||
|
|
|
||||||
|
|
@ -9,102 +9,3 @@ function _hamming(str1::AbstractString, str2::AbstractString)
|
||||||
throw(DimensionMismatch("strings must be of equal length"))
|
throw(DimensionMismatch("strings must be of equal length"))
|
||||||
return sum(c -> first(c) != last(c), zip(str1, str2))
|
return sum(c -> first(c) != last(c), zip(str1, str2))
|
||||||
end #function
|
end #function
|
||||||
|
|
||||||
"""
|
|
||||||
cualer_id(u::UUID; length::Integer = 29)
|
|
||||||
|
|
||||||
Convert `u` to a base30 CualerID, truncating all but the last `length` digits as
|
|
||||||
the human-readable representation of `u`
|
|
||||||
"""
|
|
||||||
function cualer_id(u::UUID; length::Integer = 29)
|
|
||||||
length > 29 &&
|
|
||||||
throw(BoundsError("CualerIDs cannot be printed at lengths longer than 29"))
|
|
||||||
return base30encode(u; pad = length)[(end-(length-1)):end]
|
|
||||||
end #function
|
|
||||||
|
|
||||||
"""
|
|
||||||
mint_ids!(
|
|
||||||
[existing_ids::Vector{UUID}],
|
|
||||||
desired_total::Integer,
|
|
||||||
desired_length::Integer,
|
|
||||||
failure_threshold::AbstractFloat,
|
|
||||||
)
|
|
||||||
|
|
||||||
Creates `desired_total` number of `UUID`s that are valid CualerIDs at a `desired_length`
|
|
||||||
|
|
||||||
# Arguments
|
|
||||||
- `existing_ids::Vector{UUID}`: A set of existing CualerIDs that have already been
|
|
||||||
validated. The default is an empty array, i.e. construct an entirely new set of CualerIDs.
|
|
||||||
- `desired_total::Integer`: The length to grow `existing_ids` to
|
|
||||||
- `desired_length::Integer`: The length of the CualerID string that is compared to check for
|
|
||||||
conflicts
|
|
||||||
- `failure_threshold::AbstractFloat`: The fraction of non-conflicting values (between 0 and
|
|
||||||
1) that is required
|
|
||||||
"""
|
|
||||||
function mint_ids!(
|
|
||||||
existing_ids::Vector{UUID},
|
|
||||||
desired_total::Integer,
|
|
||||||
desired_length::Integer,
|
|
||||||
failure_threshold::AbstractFloat,
|
|
||||||
)
|
|
||||||
# Exception to my recent thirst for "parse, don't validate"
|
|
||||||
# We could technically make failure_threshold a `Normed{T,f}` value from
|
|
||||||
# FixedPointNumbers.jl, but that would
|
|
||||||
# a) Require taking a dependency on FixedPointNumbers.jl
|
|
||||||
# b) Require all dependents to also depend on FixedPointNumbers.jl in order to
|
|
||||||
# properly call this function
|
|
||||||
if failure_threshold < 0 || failure_threshold > 1
|
|
||||||
throw(
|
|
||||||
DomainError(
|
|
||||||
failure_threshold,
|
|
||||||
"`failure_threshold` must be between 0.0 and 1.0",
|
|
||||||
),
|
|
||||||
)
|
|
||||||
end #if
|
|
||||||
|
|
||||||
# Strategy to grow the vector:
|
|
||||||
# a) Check how many elements are needed
|
|
||||||
# b) Add unvalidated elements
|
|
||||||
# c) Validate new elements against all elements up to itself
|
|
||||||
# d) Delete invalid elements
|
|
||||||
# e) Repeat
|
|
||||||
existing_length = length(existing_ids)
|
|
||||||
needed_to_fill = desired_total - existing_length
|
|
||||||
failed_ids = Int[]
|
|
||||||
|
|
||||||
push!(existing_ids, [uuid4() for i = 1:needed_to_fill]...)
|
|
||||||
|
|
||||||
for i = (existing_length+1):desired_total
|
|
||||||
for j = 1:(i-1)
|
|
||||||
if _hamming(
|
|
||||||
cualer_id(existing_ids[i]; length = desired_length),
|
|
||||||
cualer_id(existing_ids[j], length = desired_length),
|
|
||||||
) < 3
|
|
||||||
push!(failed_ids, i)
|
|
||||||
@debug """
|
|
||||||
Conflict found between
|
|
||||||
$(existing_ids[i]) ($(cualer_id(existing_ids[i])))
|
|
||||||
and
|
|
||||||
$(existing_ids[j]) ($(cualer_id(existing_ids[i])))
|
|
||||||
"""
|
|
||||||
break
|
|
||||||
end #if
|
|
||||||
end #for
|
|
||||||
end #for
|
|
||||||
|
|
||||||
if 1 - length(failed_ids) / desired_total > failure_threshold
|
|
||||||
return existing_ids
|
|
||||||
else
|
|
||||||
return mint_ids!(existing_ids, desired_total, desired_length, failure_threshold)
|
|
||||||
end #if
|
|
||||||
end #function
|
|
||||||
|
|
||||||
|
|
||||||
function mint_ids!(
|
|
||||||
desired_total::Integer,
|
|
||||||
desired_length::Integer,
|
|
||||||
failure_threshold::AbstractFloat,
|
|
||||||
)
|
|
||||||
return mint_ids!(UUID[], desired_total, desired_length, failure_threshold)
|
|
||||||
|
|
||||||
end #function
|
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ function Base.show(io::IO, r::ResultCodeOption)
|
||||||
c -> r.val & UInt8(c) != 0 && print(io, string(Symbol(c))),
|
c -> r.val & UInt8(c) != 0 && print(io, string(Symbol(c))),
|
||||||
instances(ResultCode),
|
instances(ResultCode),
|
||||||
)
|
)
|
||||||
return print(io, ")")
|
print(io, ")")
|
||||||
end #function
|
end #function
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -1,46 +0,0 @@
|
||||||
@enum ResultCodeOptionErrCode::UInt8 begin
|
|
||||||
RESULTCODEOPTION_InvalidOption
|
|
||||||
RESULTCODEOPTION_NoOptions
|
|
||||||
end #@enum
|
|
||||||
|
|
||||||
struct ResultCodeOptionError <: OptParse.AbstractParseError
|
|
||||||
code::ResultCodeOptionErrCode
|
|
||||||
token::String
|
|
||||||
end #struct
|
|
||||||
|
|
||||||
function OptParse.render_error(io::IO, err::ResultCodeOptionError)
|
|
||||||
return if err.code == RESULTCODEOPTION_InvalidOption
|
|
||||||
print(io, "Expected valid ResultCode (D, F, N, or V), got $(err.token)")
|
|
||||||
elseif err.code == RESULTCODEOPTION_NoOptions
|
|
||||||
print(io, "Must include one ResultCode")
|
|
||||||
else
|
|
||||||
@assert false "unreachable"
|
|
||||||
end #if
|
|
||||||
end #function
|
|
||||||
|
|
||||||
@kwdef struct ResultCodeOptionVal{T} <:
|
|
||||||
OptParse.AbstractValueParser{T,ResultCodeOptionError}
|
|
||||||
metavar::String = "RESULT_CODES"
|
|
||||||
end #struct
|
|
||||||
|
|
||||||
(rco::ResultCodeOptionVal{T})(input::AbstractString) where {T} =
|
|
||||||
let
|
|
||||||
val = uppercase(input)
|
|
||||||
occursin(r"[^DFNV]", val) && return OptParse.Result{T,ResultCodeOptionError}'.Err(
|
|
||||||
ResultCodeOptionError(RESULTCODEOPTION_InvalidOption, input),
|
|
||||||
)
|
|
||||||
|
|
||||||
occursin(r"[DFNV]", val) || return OptParse.Result{T,ResultCodeOptionError}'.Err(
|
|
||||||
ResultCodeOptionError(RESULTCODEOPTION_NoOptions, input),
|
|
||||||
)
|
|
||||||
|
|
||||||
return OptParse.Result{T,ResultCodeOptionError}'.Ok(parse(ResultCodeOption, input))
|
|
||||||
end #let
|
|
||||||
|
|
||||||
result_code_option(::Type{T}; kw...) where {T<:ResultCodeOption} =
|
|
||||||
ResultCodeOptionVal{T}(; kw...)
|
|
||||||
result_code_option(metavar::AbstractString, ::Type{T}; kw...) where {T<:ResultCodeOption} =
|
|
||||||
ResultCodeOptionVal{T}(; metavar = String(metavar), kw...)
|
|
||||||
result_code_option(; kw...) = ResultCodeOptionVal{ResultCodeOption}(; kw...)
|
|
||||||
result_code_option(metavar::AbstractString; kw...) =
|
|
||||||
ResultCodeOptionVal{ResultCodeOption}(; metavar = String(metavar), kw...)
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue