From f04b2a166f44e2a664e7e9a88f634b54d4a9f256 Mon Sep 17 00:00:00 2001 From: Kenta Sato Date: Fri, 3 Mar 2017 10:37:22 +0900 Subject: [PATCH] fix deprecated syntax for Julia 0.6 --- REQUIRE | 1 + src/DocOpt.jl | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/REQUIRE b/REQUIRE index d5d6467..fb39ab0 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1 +1,2 @@ julia 0.4 +Compat 0.17 diff --git a/src/DocOpt.jl b/src/DocOpt.jl index 9930b3e..90183f5 100644 --- a/src/DocOpt.jl +++ b/src/DocOpt.jl @@ -4,6 +4,8 @@ module DocOpt export docopt +import Compat: @compat + import Base: == # port of str.partition in Python @@ -31,9 +33,9 @@ type DocOptExit <: Exception usage::AbstractString end -abstract Pattern -abstract LeafPattern <: Pattern -abstract BranchPattern <: Pattern +@compat abstract type Pattern end +@compat abstract type LeafPattern <: Pattern end +@compat abstract type BranchPattern <: Pattern end type Argument <: LeafPattern name @@ -80,7 +82,7 @@ type Option <: LeafPattern end end -typealias Children Vector{Pattern} +const Children = Vector{Pattern} type Required <: BranchPattern children::Children @@ -348,7 +350,7 @@ function parse_long(tokens::Tokens, options) value = eq == value == "" ? nothing : value similar = filter(o -> o.long == long, options) if tokens.error === DocOptExit && isempty(similar) # if no exact match - similar = filter(o -> !is(o.long, nothing) && startswith(o.long, long), options) + similar = filter(o -> o.long !== nothing && startswith(o.long, long), options) end if length(similar) > 1 # might be simply specified ambiguously 2+ times? throw(tokens.error("$long is not a unique prefix: $(join(map(s -> s.long, similar), ","))")) @@ -476,7 +478,7 @@ function parse_atom(tokens, options) return parse_long(tokens, options) elseif startswith(token, '-') && !isdash(token) return parse_shorts(tokens, options) - elseif startswith(token, '<') && endswith(token, '>') || isupper(token) + elseif startswith(token, '<') && endswith(token, '>') || all(isupper, token) return [Argument(move!(tokens))] else return [Command(move!(tokens))]