Skip to content

Commit e64753c

Browse files
committed
Throw error when both --skip and --all were specified, rename clean_call to clean_all, clean up code
1 parent ee397ac commit e64753c

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

src/fpm.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ subroutine cmd_clean(settings)
687687

688688
if (is_dir('build')) then
689689
! Remove the entire build directory
690-
if (settings%clean_call) then
690+
if (settings%clean_all) then
691691
call os_delete_dir(os_is_unix(), 'build'); return
692692
end if
693693

src/fpm_command_line.f90

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ module fpm_command_line
113113

114114
type, extends(fpm_cmd_settings) :: fpm_clean_settings
115115
logical :: clean_skip = .false.
116-
logical :: clean_call = .false.
116+
logical :: clean_all = .false.
117117
end type
118118

119119
type, extends(fpm_build_settings) :: fpm_publish_settings
@@ -606,11 +606,22 @@ subroutine get_command_line_settings(cmd_settings)
606606
& ' --skip' // &
607607
& ' --all', &
608608
help_clean, version_text)
609-
allocate(fpm_clean_settings :: cmd_settings)
610-
call get_current_directory(working_dir, error)
611-
cmd_settings=fpm_clean_settings( &
612-
& clean_skip=lget('skip'), &
613-
& clean_call=lget('all'))
609+
610+
block
611+
logical :: skip, clean_all
612+
613+
skip = lget('skip')
614+
clean_all = lget('all')
615+
616+
if (all([skip, clean_all])) then
617+
call fpm_stop(6, 'Do not specify both --skip and --all options on the clean subcommand.')
618+
end if
619+
620+
allocate(fpm_clean_settings :: cmd_settings)
621+
cmd_settings=fpm_clean_settings( &
622+
& clean_skip=skip, &
623+
& clean_all=clean_all)
624+
end block
614625

615626
case('publish')
616627
call set_args(common_args // compiler_args //'&

test/cli_test/cli_test.f90

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ subroutine parse()
264264
if (allocated(settings%args)) act_args=settings%args
265265
type is (fpm_clean_settings)
266266
act_c_s=settings%clean_skip
267-
act_c_a=settings%clean_call
267+
act_c_a=settings%clean_all
268268
type is (fpm_install_settings)
269269
type is (fpm_publish_settings)
270270
act_show_v=settings%show_package_version
@@ -275,7 +275,6 @@ subroutine parse()
275275

276276
open(file='_test_cli',newunit=lun,delim='quote')
277277
write(lun,nml=act_cli,delim='quote')
278-
!!write(*,nml=act_cli)
279278
close(unit=lun)
280279

281280
end subroutine parse

0 commit comments

Comments
 (0)