Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions src/plugins/license.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,30 @@ function prompt(::Type{License}, ::Type, ::Val{:name})
# Move MIT to the top.
deleteat!(options, findfirst(==("MIT"), options))
pushfirst!(options, "MIT")
menu = RadioMenu(options; pagesize=length(options))
println("Select a license:")
menu = RadioMenu(map(license_display_name, options); pagesize=length(options))
println("Select a license (abbreviation - full name):")
idx = request(menu)
return options[idx]
end

customizable(::Type{License}) = (:name => String,)

function license_display_name(name::AbstractString)
full_name = get(LICENSE_NAMES, name, name)
return full_name == name ? name : "$(name) - $(full_name)"
end

const LICENSE_NAMES = Dict(
"AGPL-3.0+" => "GNU Affero General Public License v3.0 or later",
"ASL" => "Apache License 2.0",
"BSD2" => "BSD 2-Clause License",
"BSD3" => "BSD 3-Clause License",
"EUPL-1.2+" => "European Union Public Licence 1.2 or later",
"GPL-2.0+" => "GNU General Public License v2.0 or later",
"GPL-3.0+" => "GNU General Public License v3.0 or later",
"ISC" => "ISC License",
"LGPL-2.1+" => "GNU Lesser General Public License v2.1 or later",
"LGPL-3.0+" => "GNU Lesser General Public License v3.0 or later",
"MIT" => "MIT License",
"MPL" => "Mozilla Public License 2.0",
)
6 changes: 5 additions & 1 deletion test/interactive.jl
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,11 @@ end
"COPYING", LF, # Enter destination
CR, # Choose MIT for name (it's at the top)
)
@test PT.interactive(License) == License(; destination="COPYING", name="MIT")
license = @suppress PT.interactive(License)
@test occursin("Select a license (abbreviation - full name):", license.output)
@test occursin("MIT - MIT License", license.output)
@test occursin("ASL - Apache License 2.0", license.output)
@test license.ret == License(; destination="COPYING", name="MIT")
end

@testset "Quotes" begin
Expand Down
Loading