Skip to content

Commit df4463d

Browse files
authored
Fix: fpm stopped running after printing help (#728)
Stop fpm​​ from running after printing help_text.
2 parents 4fb72da + 67492b4 commit df4463d

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

src/fpm.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module fpm
77
fpm_clean_settings
88
use fpm_dependency, only : new_dependency_tree
99
use fpm_environment, only: get_env
10-
use fpm_filesystem, only: is_dir, join_path, number_of_rows, list_files, exists, &
10+
use fpm_filesystem, only: is_dir, join_path, list_files, exists, &
1111
basename, filewrite, mkdir, run, os_delete_dir
1212
use fpm_model, only: fpm_model_t, srcfile_t, show_model, &
1313
FPM_SCOPE_UNKNOWN, FPM_SCOPE_LIB, FPM_SCOPE_DEP, &

src/fpm_command_line.f90

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,9 @@ module fpm_command_line
192192
subroutine get_command_line_settings(cmd_settings)
193193
class(fpm_cmd_settings), allocatable, intent(out) :: cmd_settings
194194

195+
integer, parameter :: widest = 256
195196
character(len=4096) :: cmdarg
196197
integer :: i
197-
integer :: widest
198198
integer :: os
199199
logical :: unix
200200
type(fpm_install_settings), allocatable :: install_settings
@@ -434,7 +434,6 @@ subroutine get_command_line_settings(cmd_settings)
434434
elseif(unnamed(2)=='manual')then
435435
unnamed=manual
436436
endif
437-
widest=256
438437
allocate(character(len=widest) :: help_text(0))
439438
do i=2,size(unnamed)
440439
select case(unnamed(i))
@@ -507,10 +506,12 @@ subroutine get_command_line_settings(cmd_settings)
507506
call set_args(common_args // '&
508507
& --list F&
509508
&', help_list, version_text)
510-
call printhelp(help_list_nodash)
511509
if(lget('list'))then
512-
call printhelp(help_list_dash)
510+
help_text = [character(widest) :: help_list_nodash, help_list_dash]
511+
else
512+
help_text = help_list_nodash
513513
endif
514+
call printhelp(help_text)
514515

515516
case('test')
516517
call set_args(common_args // compiler_args // run_args // ' --', &
@@ -592,23 +593,23 @@ subroutine get_command_line_settings(cmd_settings)
592593

593594
if(cmdarg.ne.''.and.which('fpm-'//cmdarg).ne.'')then
594595
call run('fpm-'//trim(cmdarg)//' '// get_command_arguments_quoted(),.false.)
596+
stop
595597
else
596598
call set_args('&
597599
& --list F&
598600
&', help_fpm, version_text)
599601
! Note: will not get here if --version or --usage or --help
600602
! is present on commandline
601-
help_text=help_usage
602603
if(lget('list'))then
603-
help_text=help_list_dash
604+
help_text = help_list_dash
604605
elseif(len_trim(cmdarg)==0)then
605606
write(stdout,'(*(a))')'Fortran Package Manager:'
606607
write(stdout,'(*(a))')' '
607-
call printhelp(help_list_nodash)
608+
help_text = [character(widest) :: help_list_nodash, help_usage]
608609
else
609610
write(stderr,'(*(a))')'<ERROR> unknown subcommand [', &
610611
& trim(cmdarg), ']'
611-
call printhelp(help_list_dash)
612+
help_text = [character(widest) :: help_list_dash, help_usage]
612613
endif
613614
call printhelp(help_text)
614615
endif
@@ -638,6 +639,7 @@ subroutine check_build_vals()
638639

639640
end subroutine check_build_vals
640641

642+
!> Print help text and stop
641643
subroutine printhelp(lines)
642644
character(len=:),intent(in),allocatable :: lines(:)
643645
integer :: iii,ii
@@ -649,6 +651,7 @@ subroutine printhelp(lines)
649651
write(stdout,'(a)')'<WARNING> *printhelp* output requested is empty'
650652
endif
651653
endif
654+
stop
652655
end subroutine printhelp
653656

654657
end subroutine get_command_line_settings

0 commit comments

Comments
 (0)