Start implementing the interactive plugin constructors
This commit is contained in:
parent
17e3927eb1
commit
3f886525a7
@ -11,7 +11,7 @@ using REPL.TerminalMenus: MultiSelectMenu, RadioMenu, request
|
|||||||
using UUIDs: uuid4
|
using UUIDs: uuid4
|
||||||
|
|
||||||
using Mustache: render
|
using Mustache: render
|
||||||
using Parameters: @with_kw_noshow
|
using Parameters: with_kw
|
||||||
|
|
||||||
export
|
export
|
||||||
Template,
|
Template,
|
||||||
|
@ -235,6 +235,36 @@ If you are implementing a plugin that uses the `user` field of a [`Template`](@r
|
|||||||
"""
|
"""
|
||||||
needs_username(::Plugin) = false
|
needs_username(::Plugin) = false
|
||||||
|
|
||||||
|
"""
|
||||||
|
@with_defaults struct T #= ... =# end
|
||||||
|
|
||||||
|
Wraps Parameters.jl's [`@with_kw_noshow`](https://mauro3.github.io/Parameters.jl/stable/api/#Parameters.@with_kw_noshow-Tuple{Any}) to generate keyword constructors,
|
||||||
|
|
||||||
|
TODO explain prompt syntax.
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
```julia
|
||||||
|
struct Foo <: Plugin
|
||||||
|
file::String = "/dev/null" <- "Path to the file to use"
|
||||||
|
n::Int <- "This one has no default, but this is the interactive prompt"
|
||||||
|
xyz::String = "Without a prompt, defaultkw is not implemented for this field"
|
||||||
|
end
|
||||||
|
```
|
||||||
|
"""
|
||||||
|
macro with_defaults(ex::Expr)
|
||||||
|
T = esc(ex.args[2].args[1])
|
||||||
|
|
||||||
|
# TODO: Parse out `<- "prompt"` stuff.
|
||||||
|
funcs = map(filter(arg -> arg isa Expr && arg.head === :(=), ex.args[3].args)) do arg
|
||||||
|
name = QuoteNode(arg.args[1].args[1])
|
||||||
|
val = arg.args[2]
|
||||||
|
:(PkgTemplates.defaultkw(::Type{$T}, ::Val{$name}) = $(esc(arg.args[2])))
|
||||||
|
end
|
||||||
|
|
||||||
|
return Expr(:block, esc(with_kw(ex, __module__, false)), funcs...)
|
||||||
|
end
|
||||||
|
|
||||||
include(joinpath("plugins", "project_file.jl"))
|
include(joinpath("plugins", "project_file.jl"))
|
||||||
include(joinpath("plugins", "src_dir.jl"))
|
include(joinpath("plugins", "src_dir.jl"))
|
||||||
include(joinpath("plugins", "tests.jl"))
|
include(joinpath("plugins", "tests.jl"))
|
||||||
|
@ -44,7 +44,7 @@ Integrates your packages with [Travis CI](https://travis-ci.com).
|
|||||||
- `coverage::Bool`: Whether or not to publish code coverage (another code coverage plugin such as [`Codecov`](@ref) must also be included).
|
- `coverage::Bool`: Whether or not to publish code coverage (another code coverage plugin such as [`Codecov`](@ref) must also be included).
|
||||||
$EXTRA_VERSIONS_DOC
|
$EXTRA_VERSIONS_DOC
|
||||||
"""
|
"""
|
||||||
@with_kw_noshow struct TravisCI <: BasicPlugin
|
@with_defaults struct TravisCI <: BasicPlugin
|
||||||
file::String = default_file("travis.yml")
|
file::String = default_file("travis.yml")
|
||||||
linux::Bool = true
|
linux::Bool = true
|
||||||
osx::Bool = true
|
osx::Bool = true
|
||||||
@ -113,7 +113,7 @@ Integrates your packages with [AppVeyor](https://appveyor.com) via [AppVeyor.jl]
|
|||||||
- `coverage::Bool`: Whether or not to publish code coverage ([`Codecov`](@ref) must also be included).
|
- `coverage::Bool`: Whether or not to publish code coverage ([`Codecov`](@ref) must also be included).
|
||||||
$EXTRA_VERSIONS_DOC
|
$EXTRA_VERSIONS_DOC
|
||||||
"""
|
"""
|
||||||
@with_kw_noshow struct AppVeyor <: BasicPlugin
|
@with_defaults struct AppVeyor <: BasicPlugin
|
||||||
file::String = default_file("appveyor.yml")
|
file::String = default_file("appveyor.yml")
|
||||||
x86::Bool = false
|
x86::Bool = false
|
||||||
coverage::Bool = true
|
coverage::Bool = true
|
||||||
@ -166,7 +166,7 @@ $EXTRA_VERSIONS_DOC
|
|||||||
!!! note
|
!!! note
|
||||||
Code coverage submission from Cirrus CI is not yet supported by [Coverage.jl](https://github.com/JuliaCI/Coverage.jl).
|
Code coverage submission from Cirrus CI is not yet supported by [Coverage.jl](https://github.com/JuliaCI/Coverage.jl).
|
||||||
"""
|
"""
|
||||||
@with_kw_noshow struct CirrusCI <: BasicPlugin
|
@with_defaults struct CirrusCI <: BasicPlugin
|
||||||
file::String = default_file("cirrus.yml")
|
file::String = default_file("cirrus.yml")
|
||||||
image::String = "freebsd-12-0-release-amd64"
|
image::String = "freebsd-12-0-release-amd64"
|
||||||
coverage::Bool = true
|
coverage::Bool = true
|
||||||
@ -215,7 +215,7 @@ See [`Documenter`](@ref) for more information.
|
|||||||
!!! note
|
!!! note
|
||||||
Nightly Julia is not supported.
|
Nightly Julia is not supported.
|
||||||
"""
|
"""
|
||||||
@with_kw_noshow struct GitLabCI <: BasicPlugin
|
@with_defaults struct GitLabCI <: BasicPlugin
|
||||||
file::String = default_file("gitlab-ci.yml")
|
file::String = default_file("gitlab-ci.yml")
|
||||||
coverage::Bool = true
|
coverage::Bool = true
|
||||||
# Nightly has no Docker image.
|
# Nightly has no Docker image.
|
||||||
|
@ -7,7 +7,7 @@ Creates a `CITATION.bib` file for citing package repositories.
|
|||||||
- `file::AbstractString`: Template file for `CITATION.bib`.
|
- `file::AbstractString`: Template file for `CITATION.bib`.
|
||||||
- `readme::Bool`: Whether or not to include a section about citing in the README.
|
- `readme::Bool`: Whether or not to include a section about citing in the README.
|
||||||
"""
|
"""
|
||||||
@with_kw_noshow struct Citation <: BasicPlugin
|
@with_defaults struct Citation <: BasicPlugin
|
||||||
file::String = default_file("CITATION.bib")
|
file::String = default_file("CITATION.bib")
|
||||||
readme::Bool = false
|
readme::Bool = false
|
||||||
end
|
end
|
||||||
|
@ -8,7 +8,7 @@ Sets up code coverage submission from CI to [Codecov](https://codecov.io).
|
|||||||
## Keyword Arguments
|
## Keyword Arguments
|
||||||
- `file::Union{AbstractString, Nothing}`: Template file for `.codecov.yml`, or `nothing` to create no file.
|
- `file::Union{AbstractString, Nothing}`: Template file for `.codecov.yml`, or `nothing` to create no file.
|
||||||
"""
|
"""
|
||||||
@with_kw_noshow struct Codecov <: BasicPlugin
|
@with_defaults struct Codecov <: BasicPlugin
|
||||||
file::Union{String, Nothing} = nothing
|
file::Union{String, Nothing} = nothing
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ Sets up code coverage submission from CI to [Coveralls](https://coveralls.io).
|
|||||||
## Keyword Arguments
|
## Keyword Arguments
|
||||||
- `file::Union{AbstractString, Nothing}`: Template file for `.coveralls.yml`, or `nothing` to create no file.
|
- `file::Union{AbstractString, Nothing}`: Template file for `.coveralls.yml`, or `nothing` to create no file.
|
||||||
"""
|
"""
|
||||||
@with_kw_noshow struct Coveralls <: BasicPlugin
|
@with_defaults struct Coveralls <: BasicPlugin
|
||||||
file::Union{String, Nothing} = nothing
|
file::Union{String, Nothing} = nothing
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ struct Documenter{T<:Union{TravisCI, GitLabCI, Nothing}} <: Plugin
|
|||||||
make_jl::String
|
make_jl::String
|
||||||
index_md::String
|
index_md::String
|
||||||
|
|
||||||
# Can't use @with_kw_noshow due to some weird precompilation issues.
|
# Can't use @with_defaults due to some weird precompilation issues.
|
||||||
function Documenter{T}(;
|
function Documenter{T}(;
|
||||||
assets::Vector{<:AbstractString}=String[],
|
assets::Vector{<:AbstractString}=String[],
|
||||||
makedocs_kwargs::Dict{Symbol}=Dict{Symbol, Any}(),
|
makedocs_kwargs::Dict{Symbol}=Dict{Symbol, Any}(),
|
||||||
|
@ -12,7 +12,7 @@ Creates a Git repository and a `.gitignore` file.
|
|||||||
- `gpgsign::Bool`: Whether or not to sign commits with your GPG key.
|
- `gpgsign::Bool`: Whether or not to sign commits with your GPG key.
|
||||||
This option requires that the Git CLI is installed, and for you to have a GPG key associated with your committer identity.
|
This option requires that the Git CLI is installed, and for you to have a GPG key associated with your committer identity.
|
||||||
"""
|
"""
|
||||||
@with_kw_noshow struct Git <: Plugin
|
@with_defaults struct Git <: Plugin
|
||||||
ignore::Vector{String} = []
|
ignore::Vector{String} = []
|
||||||
ssh::Bool = false
|
ssh::Bool = false
|
||||||
manifest::Bool = false
|
manifest::Bool = false
|
||||||
|
@ -14,7 +14,7 @@ By default, it includes badges for other included plugins
|
|||||||
For example, values of `"README"` or `"README.rst"` might be desired.
|
For example, values of `"README"` or `"README.rst"` might be desired.
|
||||||
- `inline_badges::Bool`: Whether or not to put the badges on the same line as the package name.
|
- `inline_badges::Bool`: Whether or not to put the badges on the same line as the package name.
|
||||||
"""
|
"""
|
||||||
@with_kw_noshow struct Readme <: BasicPlugin
|
@with_defaults struct Readme <: BasicPlugin
|
||||||
file::String = default_file("README.md")
|
file::String = default_file("README.md")
|
||||||
destination::String = "README.md"
|
destination::String = "README.md"
|
||||||
inline_badges::Bool = false
|
inline_badges::Bool = false
|
||||||
|
@ -6,7 +6,7 @@ Creates a module entrypoint.
|
|||||||
## Keyword Arguments
|
## Keyword Arguments
|
||||||
- `file::AbstractString`: Template file for `src/<module>.jl`.
|
- `file::AbstractString`: Template file for `src/<module>.jl`.
|
||||||
"""
|
"""
|
||||||
@with_kw_noshow mutable struct SrcDir <: BasicPlugin
|
@with_defaults mutable struct SrcDir <: BasicPlugin
|
||||||
file::String = default_file("src", "module.jl")
|
file::String = default_file("src", "module.jl")
|
||||||
destination::String = joinpath("src", "<module>.jl")
|
destination::String = joinpath("src", "<module>.jl")
|
||||||
end
|
end
|
||||||
|
@ -14,7 +14,7 @@ Sets up testing for packages.
|
|||||||
!!! note
|
!!! note
|
||||||
Managing test dependencies with `test/Project.toml` is only supported in Julia 1.2 and later.
|
Managing test dependencies with `test/Project.toml` is only supported in Julia 1.2 and later.
|
||||||
"""
|
"""
|
||||||
@with_kw_noshow struct Tests <: BasicPlugin
|
@with_defaults struct Tests <: BasicPlugin
|
||||||
file::String = default_file("test", "runtests.jl")
|
file::String = default_file("test", "runtests.jl")
|
||||||
project::Bool = false
|
project::Bool = false
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user