Entry point for the update subcommand
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(fpm_update_settings), | intent(in) | :: | settings |
Representation of the command line arguments |
subroutine cmd_update(settings)
!> Representation of the command line arguments
type(fpm_update_settings), intent(in) :: settings
type(package_config_t) :: package
type(dependency_tree_t) :: deps
type(error_t), allocatable :: error
integer :: ii
character(len=:), allocatable :: cache
call get_package_data(package, "fpm.toml", error, apply_defaults=.true.)
call handle_error(error)
if (.not. exists("build")) then
call mkdir("build")
call filewrite(join_path("build", ".gitignore"),["*"])
end if
cache = join_path("build", "cache.toml")
if (settings%clean) call delete_file(cache)
call new_dependency_tree(deps, cache=cache, &
verbosity=merge(2, 1, settings%verbose))
call deps%add(package, error)
call handle_error(error)
! Force-update all dependencies if `--clean`
if (settings%clean) then
do ii = 1, deps%ndep
deps%dep(ii)%update = .true.
end do
end if
if (settings%fetch_only) return
if (size(settings%name) == 0) then
call deps%update(error)
call handle_error(error)
else
do ii = 1, size(settings%name)
call deps%update(trim(settings%name(ii)), error)
call handle_error(error)
end do
end if
end subroutine cmd_update