Replace Void/Nullables

This commit is contained in:
Chris de Graaf 2018-09-17 14:40:09 -05:00
parent f070978334
commit 632283b847
8 changed files with 27 additions and 25 deletions

View File

@ -2,6 +2,8 @@ __precompile__()
module PkgTemplates module PkgTemplates
using AutoHashEquals using AutoHashEquals
using Dates
using Distributed
using Mustache using Mustache
using TerminalMenus using TerminalMenus
using URIParser using URIParser

View File

@ -7,7 +7,7 @@ Generic plugins are plugins that add any number of patterns to the generated pac
# Attributes # Attributes
* `gitignore::Vector{AbstractString}`: Array of patterns to be added to the `.gitignore` of * `gitignore::Vector{AbstractString}`: Array of patterns to be added to the `.gitignore` of
generated packages that use this plugin. generated packages that use this plugin.
* `src::Nullable{AbstractString}`: Path to the file that will be copied into the generated * `src::Union{AbstractString, Nothing}`: Path to the file that will be copied into the generated
package repository. If set to `nothing`, no file will be generated. When this defaults package repository. If set to `nothing`, no file will be generated. When this defaults
to an empty string, there should be a default file in `defaults` that will be copied. to an empty string, there should be a default file in `defaults` that will be copied.
That file's name is usually the same as the plugin's name, except in all lowercase and That file's name is usually the same as the plugin's name, except in all lowercase and
@ -25,7 +25,7 @@ Generic plugins are plugins that add any number of patterns to the generated pac
```julia ```julia
@auto_hash_equals struct MyPlugin <: GenericPlugin @auto_hash_equals struct MyPlugin <: GenericPlugin
gitignore::Vector{AbstractString} gitignore::Vector{AbstractString}
src::Nullable{AbstractString} src::Union{AbstractString, Nothing}
dest::AbstractString dest::AbstractString
badges::Vector{Badge} badges::Vector{Badge}
view::Dict{String, Any} view::Dict{String, Any}

View File

@ -1,21 +1,21 @@
""" """
AppVeyor(; config_file::Union{AbstractString, Void}="") -> AppVeyor AppVeyor(; config_file::Union{AbstractString, Nothing}="") -> AppVeyor
Add `AppVeyor` to a template's plugins to add a `.appveyor.yml` configuration file to Add `AppVeyor` to a template's plugins to add a `.appveyor.yml` configuration file to
generated repositories, and an appropriate badge to the README. generated repositories, and an appropriate badge to the README.
# Keyword Arguments # Keyword Arguments
* `config_file::Union{AbstractString, Void}=""`: Path to a custom `.appveyor.yml`. * `config_file::Union{AbstractString, Nothing}=""`: Path to a custom `.appveyor.yml`.
If `nothing` is supplied, no file will be generated. If `nothing` is supplied, no file will be generated.
""" """
@auto_hash_equals struct AppVeyor <: GenericPlugin @auto_hash_equals struct AppVeyor <: GenericPlugin
gitignore::Vector{AbstractString} gitignore::Vector{AbstractString}
src::Nullable{AbstractString} src::Union{AbstractString, Nothing}
dest::AbstractString dest::AbstractString
badges::Vector{Badge} badges::Vector{Badge}
view::Dict{String, Any} view::Dict{String, Any}
function AppVeyor(; config_file::Union{AbstractString, Void}="") function AppVeyor(; config_file::Union{AbstractString, Nothing}="")
if config_file != nothing if config_file != nothing
config_file = if isempty(config_file) config_file = if isempty(config_file)
config_file = joinpath(DEFAULTS_DIR, "appveyor.yml") config_file = joinpath(DEFAULTS_DIR, "appveyor.yml")

View File

@ -1,22 +1,22 @@
""" """
CodeCov(; config_file::Union{AbstractString, Void}=nothing) -> CodeCov CodeCov(; config_file::Union{AbstractString, Nothing}=nothing) -> CodeCov
Add `CodeCov` to a template's plugins to optionally add a `.codecov.yml` configuration file Add `CodeCov` to a template's plugins to optionally add a `.codecov.yml` configuration file
to generated repositories, and an appropriate badge to the README. Also updates the to generated repositories, and an appropriate badge to the README. Also updates the
`.gitignore` accordingly. `.gitignore` accordingly.
# Keyword Arguments: # Keyword Arguments:
* `config_file::Union{AbstractString, Void}=nothing`: Path to a custom `.codecov.yml`. * `config_file::Union{AbstractString, Nothing}=nothing`: Path to a custom `.codecov.yml`.
If left unset, no file will be generated. If left unset, no file will be generated.
""" """
@auto_hash_equals struct CodeCov <: GenericPlugin @auto_hash_equals struct CodeCov <: GenericPlugin
gitignore::Vector{AbstractString} gitignore::Vector{AbstractString}
src::Nullable{AbstractString} src::Union{AbstractString, Nothing}
dest::AbstractString dest::AbstractString
badges::Vector{Badge} badges::Vector{Badge}
view::Dict{String, Any} view::Dict{String, Any}
function CodeCov(; config_file::Union{AbstractString, Void}=nothing) function CodeCov(; config_file::Union{AbstractString, Nothing}=nothing)
if config_file != nothing if config_file != nothing
config_file = if isfile(config_file) config_file = if isfile(config_file)
abspath(config_file) abspath(config_file)

View File

@ -1,22 +1,22 @@
""" """
Coveralls(; config_file::Union{AbstractString, Void}=nothing) -> Coveralls Coveralls(; config_file::Union{AbstractString, Nothing}=nothing) -> Coveralls
Add `Coveralls` to a template's plugins to optionally add a `.coveralls.yml` configuration Add `Coveralls` to a template's plugins to optionally add a `.coveralls.yml` configuration
file to generated repositories, and an appropriate badge to the README. Also updates the file to generated repositories, and an appropriate badge to the README. Also updates the
`.gitignore` accordingly. `.gitignore` accordingly.
# Keyword Arguments: # Keyword Arguments:
* `config_file::Union{AbstractString, Void}=nothing`: Path to a custom `.coveralls.yml`. * `config_file::Union{AbstractString, Nothing}=nothing`: Path to a custom `.coveralls.yml`.
If left unset, no file will be generated. If left unset, no file will be generated.
""" """
@auto_hash_equals struct Coveralls <: GenericPlugin @auto_hash_equals struct Coveralls <: GenericPlugin
gitignore::Vector{AbstractString} gitignore::Vector{AbstractString}
src::Nullable{AbstractString} src::Union{AbstractString, Nothing}
dest::AbstractString dest::AbstractString
badges::Vector{Badge} badges::Vector{Badge}
view::Dict{String, Any} view::Dict{String, Any}
function Coveralls(; config_file::Union{AbstractString, Void}=nothing) function Coveralls(; config_file::Union{AbstractString, Nothing}=nothing)
if config_file != nothing if config_file != nothing
config_file = if isfile(config_file) config_file = if isfile(config_file)
abspath(config_file) abspath(config_file)

View File

@ -25,12 +25,12 @@ function gen_plugin(
# assets/file1, # assets/file1,
# assets/file2, # assets/file2,
# ] # ]
const TAB = repeat(" ", 4) tab = repeat(" ", 4)
assets_string = "[\n" assets_string = "[\n"
for asset in plugin.assets for asset in plugin.assets
assets_string *= """$(TAB^2)"assets/$(basename(asset))",\n""" assets_string *= """$(tab^2)"assets/$(basename(asset))",\n"""
end end
assets_string *= "$TAB]" assets_string *= "$tab]"
else else
assets_string = "[]" assets_string = "[]"

View File

@ -1,23 +1,23 @@
""" """
GitLabCI(; config_file::Union{AbstractString, Void}="", coverage::Bool=true) -> GitLabCI GitLabCI(; config_file::Union{AbstractString, Nothing}="", coverage::Bool=true) -> GitLabCI
Add `GitLabCI` to a template's plugins to add a `.gitlab-ci.yml` configuration file to Add `GitLabCI` to a template's plugins to add a `.gitlab-ci.yml` configuration file to
generated repositories, and appropriate badge(s) to the README. generated repositories, and appropriate badge(s) to the README.
# Keyword Arguments: # Keyword Arguments:
* `config_file::Union{AbstractString, Void}=""`: Path to a custom `.gitlab-ci.yml`. * `config_file::Union{AbstractString, Nothing}=""`: Path to a custom `.gitlab-ci.yml`.
If `nothing` is supplied, no file will be generated. If `nothing` is supplied, no file will be generated.
* `coverage::Bool=true`: Whether or not GitLab CI's built-in code coverage analysis should * `coverage::Bool=true`: Whether or not GitLab CI's built-in code coverage analysis should
be enabled. be enabled.
""" """
@auto_hash_equals struct GitLabCI <: GenericPlugin @auto_hash_equals struct GitLabCI <: GenericPlugin
gitignore::Vector{AbstractString} gitignore::Vector{AbstractString}
src::Nullable{AbstractString} src::Union{AbstractString, Nothing}
dest::AbstractString dest::AbstractString
badges::Vector{Badge} badges::Vector{Badge}
view::Dict{String, Any} view::Dict{String, Any}
function GitLabCI(; config_file::Union{AbstractString, Void}="", coverage::Bool=true) function GitLabCI(; config_file::Union{AbstractString, Nothing}="", coverage::Bool=true)
if config_file != nothing if config_file != nothing
config_file = if isempty(config_file) config_file = if isempty(config_file)
config_file = joinpath(DEFAULTS_DIR, "gitlab-ci.yml") config_file = joinpath(DEFAULTS_DIR, "gitlab-ci.yml")

View File

@ -1,21 +1,21 @@
""" """
TravisCI(; config_file::Union{AbstractString, Void}="") -> TravisCI TravisCI(; config_file::Union{AbstractString, Nothing}="") -> TravisCI
Add `TravisCI` to a template's plugins to add a `.travis.yml` configuration file to Add `TravisCI` to a template's plugins to add a `.travis.yml` configuration file to
generated repositories, and an appropriate badge to the README. generated repositories, and an appropriate badge to the README.
# Keyword Arguments: # Keyword Arguments:
* `config_file::Union{AbstractString, Void}=""`: Path to a custom `.travis.yml`. * `config_file::Union{AbstractString, Nothing}=""`: Path to a custom `.travis.yml`.
If `nothing` is supplied, no file will be generated. If `nothing` is supplied, no file will be generated.
""" """
@auto_hash_equals struct TravisCI <: GenericPlugin @auto_hash_equals struct TravisCI <: GenericPlugin
gitignore::Vector{AbstractString} gitignore::Vector{AbstractString}
src::Nullable{AbstractString} src::Union{AbstractString, Nothing}
dest::AbstractString dest::AbstractString
badges::Vector{Badge} badges::Vector{Badge}
view::Dict{String, Any} view::Dict{String, Any}
function TravisCI(; config_file::Union{AbstractString, Void}="") function TravisCI(; config_file::Union{AbstractString, Nothing}="")
if config_file != nothing if config_file != nothing
config_file = if isempty(config_file) config_file = if isempty(config_file)
config_file = joinpath(DEFAULTS_DIR, "travis.yml") config_file = joinpath(DEFAULTS_DIR, "travis.yml")