A bit of formatting, drop Distributed dependency

This commit is contained in:
Chris de Graaf 2018-11-05 16:12:08 -06:00
parent f3b96caa65
commit 984475cd83
7 changed files with 13 additions and 17 deletions

View File

@ -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"

View File

@ -2,7 +2,6 @@ module PkgTemplates
using AutoHashEquals
using Dates
using Distributed
using InteractiveUtils
using LibGit2
using Mustache

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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")

View File

@ -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"