From 984475cd830c8a31cacffa13535f4252893289ed Mon Sep 17 00:00:00 2001 From: Chris de Graaf Date: Mon, 5 Nov 2018 16:12:08 -0600 Subject: [PATCH] A bit of formatting, drop Distributed dependency --- Project.toml | 1 - src/PkgTemplates.jl | 1 - src/plugin.jl | 10 +++++----- src/plugins/coveralls.jl | 2 +- src/plugins/documenter.jl | 6 +++--- src/plugins/travisci.jl | 2 +- src/template.jl | 8 +++----- 7 files changed, 13 insertions(+), 17 deletions(-) diff --git a/Project.toml b/Project.toml index 3ee6559..9e6e685 100644 --- a/Project.toml +++ b/Project.toml @@ -6,7 +6,6 @@ version = "0.3.0" [deps] AutoHashEquals = "15f4f7f2-30c1-5605-9d31-71845cf9641f" Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" -Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b" InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240" LibGit2 = "76f85450-5226-5b5a-8eaa-529ad045b433" Mustache = "ffc61752-8dc7-55ee-8c37-f3e9cdd09e70" diff --git a/src/PkgTemplates.jl b/src/PkgTemplates.jl index 7fc68d8..ec0965e 100644 --- a/src/PkgTemplates.jl +++ b/src/PkgTemplates.jl @@ -2,7 +2,6 @@ module PkgTemplates using AutoHashEquals using Dates -using Distributed using InteractiveUtils using LibGit2 using Mustache diff --git a/src/plugin.jl b/src/plugin.jl index 8a10b17..775a247 100644 --- a/src/plugin.jl +++ b/src/plugin.jl @@ -213,14 +213,14 @@ function badges(p::GenericPlugin, user::AbstractString, pkg_name::AbstractString end """ - interactive(t::Type{<:Plugin}; file::Union{AbstractString, Nothing}="") -> Plugin + interactive(T::Type{<:Plugin}; file::Union{AbstractString, Nothing}="") -> Plugin -Interactively create a plugin of type `t`, where `file` is the plugin type's default +Interactively create a plugin of type `T`, where `file` is the plugin type's default config template with a non-standard name (for `MyPlugin`, this is anything but "myplugin.yml"). """ -function interactive(t::Type{<:GenericPlugin}; file::Union{AbstractString, Nothing}="") - name = string(nameof(t)) +function interactive(T::Type{<:GenericPlugin}; file::Union{AbstractString, Nothing}="") + name = string(nameof(T)) # By default, we expect the default plugin file template for a plugin called # "MyPlugin" to be called "myplugin.yml". fn = file != nothing && isempty(file) ? "$(lowercase(name)).yml" : file @@ -242,5 +242,5 @@ function interactive(t::Type{<:GenericPlugin}; file::Union{AbstractString, Nothi config_file end - return t(; config_file=config_file) + return T(; config_file=config_file) end diff --git a/src/plugins/coveralls.jl b/src/plugins/coveralls.jl index 1406db7..bb6c3b7 100644 --- a/src/plugins/coveralls.jl +++ b/src/plugins/coveralls.jl @@ -40,4 +40,4 @@ file to generated repositories, and an appropriate badge to the README. Also upd end end -interactive(plugin_type::Type{Coveralls}) = interactive(plugin_type; file=nothing) +interactive(::Type{Coveralls}) = interactive(Coveralls; file=nothing) diff --git a/src/plugins/documenter.jl b/src/plugins/documenter.jl index 1e2119f..e060ef1 100644 --- a/src/plugins/documenter.jl +++ b/src/plugins/documenter.jl @@ -116,8 +116,8 @@ function Base.show(io::IO, p::Documenter) n > 0 && print(io, ": $(join(map(g -> "\"$g\"", p.gitignore), ", "))") end -function interactive(t::Type{<:Documenter}) - name = string(nameof(t)) +function interactive(T::Type{<:Documenter}) + name = string(nameof(T)) print("$name: Enter any Documenter asset files (separated by spaces) []: ") - return t(; assets=string.(split(readline()))) + return T(; assets=string.(split(readline()))) end diff --git a/src/plugins/travisci.jl b/src/plugins/travisci.jl index 1f1c46e..09ecb28 100644 --- a/src/plugins/travisci.jl +++ b/src/plugins/travisci.jl @@ -41,4 +41,4 @@ generated repositories, and an appropriate badge to the README. end end -interactive(plugin_type::Type{TravisCI}) = interactive(plugin_type; file="travis.yml") +interactive(::Type{TravisCI}) = interactive(TravisCI; file="travis.yml") diff --git a/src/template.jl b/src/template.jl index 22a8c74..3619ec9 100644 --- a/src/template.jl +++ b/src/template.jl @@ -126,7 +126,7 @@ function interactive_template(; fast::Bool=false) @info "Default values are shown in [brackets]" # Getting the leaf types in a separate thread eliminates an awkward wait after # "Select plugins" is printed. - plugin_types = @spawn leaves(Plugin) + plugin_types = @async leaves(Plugin) kwargs = Dict{Symbol, Any}() default_user = LibGit2.getconfig("github.user", "") @@ -205,13 +205,11 @@ function interactive_template(; fast::Bool=false) type_names = map(t -> split(string(t), ".")[end], plugin_types) menu = MultiSelectMenu(String.(type_names); pagesize=length(type_names)) selected = collect(request(menu)) - kwargs[:plugins] = Vector{Plugin}( - map(t -> interactive(t), getindex(plugin_types, selected)) - ) + kwargs[:plugins] = Vector{Plugin}(map(interactive, getindex(plugin_types, selected))) return Template(; kwargs...) end -leaves(t::Type)::Vector{DataType} = isconcretetype(t) ? [t] : vcat(leaves.(subtypes(t))...) +leaves(T::Type)::Vector{DataType} = isconcretetype(T) ? [T] : vcat(leaves.(subtypes(T))...) missingopt(name) = @warn "Git config option '$name' missing, package generation will fail unless you supply a GitConfig"