Skip to content

Commit

Permalink
[RFC] Make command spec more declarative (#509)
Browse files Browse the repository at this point in the history
* Refactor `REPLMode.parse_quotes`
  • Loading branch information
00vareladavid authored and KristofferC committed Feb 11, 2019
1 parent 3197d0f commit 751ff01
Show file tree
Hide file tree
Showing 3 changed files with 1,217 additions and 718 deletions.
17 changes: 15 additions & 2 deletions stdlib/Pkg/src/API.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ add_or_develop(pkg::Union{String, PackageSpec}; kwargs...) = add_or_develop([pkg
add_or_develop(pkgs::Vector{String}; kwargs...) = add_or_develop([check_package_name(pkg) for pkg in pkgs]; kwargs...)
add_or_develop(pkgs::Vector{PackageSpec}; kwargs...) = add_or_develop(Context(), pkgs; kwargs...)

function add_or_develop(ctx::Context, pkgs::Vector{PackageSpec}; mode::Symbol, devdir::Union{String,Nothing}=nothing, kwargs...)
function add_or_develop(ctx::Context, pkgs::Vector{PackageSpec}; mode::Symbol, devdir::Bool=false, kwargs...)
Context!(ctx; kwargs...)

devdir = devdir ? joinpath(dirname(ctx.env.project_file), "dev") : nothing

# All developed packages should go through handle_repos_develop so just give them an empty repo
for pkg in pkgs
mode == :develop && pkg.repo == nothing && (pkg.repo = Types.GitRepo())
Expand Down Expand Up @@ -67,7 +69,12 @@ rm(pkg::Union{String, PackageSpec}; kwargs...) = rm([pkg]; kwargs...)
rm(pkgs::Vector{String}; kwargs...) = rm([PackageSpec(pkg) for pkg in pkgs]; kwargs...)
rm(pkgs::Vector{PackageSpec}; kwargs...) = rm(Context(), pkgs; kwargs...)

function rm(ctx::Context, pkgs::Vector{PackageSpec}; kwargs...)
function rm(ctx::Context, pkgs::Vector{PackageSpec}; mode=PKGMODE_PROJECT, kwargs...)
for pkg in pkgs
#TODO only overwrite pkg.mode is default value ?
pkg.mode = mode
end

Context!(ctx; kwargs...)
ctx.preview && preview_info()
project_deps_resolve!(ctx.env, pkgs)
Expand Down Expand Up @@ -144,6 +151,12 @@ up(pkgs::Vector{PackageSpec}; kwargs...) = up(Context(), pkgs; kwargs...)

function up(ctx::Context, pkgs::Vector{PackageSpec};
level::UpgradeLevel=UPLEVEL_MAJOR, mode::PackageMode=PKGMODE_PROJECT, do_update_registry=true, kwargs...)
for pkg in pkgs
# TODO only override if they are not already set
pkg.mode = mode
pkg.version = level
end

Context!(ctx; kwargs...)
ctx.preview && preview_info()
do_update_registry && update_registry(ctx)
Expand Down
Loading

0 comments on commit 751ff01

Please sign in to comment.