diff options
author | LKedward <laurence.kedward@bristol.ac.uk> | 2020-11-08 11:37:18 +0000 |
---|---|---|
committer | LKedward <laurence.kedward@bristol.ac.uk> | 2020-11-08 11:37:18 +0000 |
commit | e15996cb01673e542a4697dfbc348b63c0bfb89e (patch) | |
tree | 5336a1f17f0a19b491e12f57dbf013a1fff75637 | |
parent | 5aa571c47f03421c95e2648b424628bb38fe7d6c (diff) | |
download | fpm-e15996cb01673e542a4697dfbc348b63c0bfb89e.tar.gz fpm-e15996cb01673e542a4697dfbc348b63c0bfb89e.zip |
Minor fix: to output formatting for run cmd
When outputting a list of available run/test targets, format the output columns nicely depending on the maximum length of the targets.
-rw-r--r-- | fpm/src/fpm.f90 | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/fpm/src/fpm.f90 b/fpm/src/fpm.f90 index 31927fc..9b5796d 100644 --- a/fpm/src/fpm.f90 +++ b/fpm/src/fpm.f90 @@ -304,7 +304,8 @@ subroutine cmd_run(settings,test) class(fpm_run_settings), intent(in) :: settings logical, intent(in) :: test - integer :: i, j + integer, parameter :: LINE_WIDTH = 80 + integer :: i, j, col_width, nCol logical :: found(size(settings%name)) type(error_t), allocatable :: error type(package_t) :: package @@ -329,6 +330,7 @@ subroutine cmd_run(settings,test) end if ! Enumerate executable targets to run + col_width = 10 found(:) = .false. allocate(executables(0)) do i=1,size(model%targets) @@ -343,6 +345,8 @@ subroutine cmd_run(settings,test) if (exe_source%unit_scope == & merge(FPM_SCOPE_TEST,FPM_SCOPE_APP,test)) then + col_width = max(col_width,len(basename(exe_target%output_file))+2) + if (size(settings%name) == 0) then exe_cmd%s = exe_target%output_file @@ -381,6 +385,7 @@ subroutine cmd_run(settings,test) write(stderr,*) j = 1 + nCol = LINE_WIDTH/col_width write(stderr,*) 'Available names:' do i=1,size(model%targets) @@ -394,8 +399,8 @@ subroutine cmd_run(settings,test) if (exe_source%unit_scope == & merge(FPM_SCOPE_TEST,FPM_SCOPE_APP,test)) then - write(stderr,'(A17)',advance=(merge("yes","no ",modulo(j,4)==0))) basename(exe_target%output_file) - + write(stderr,'(A)',advance=(merge("yes","no ",modulo(j,nCol)==0))) & + & [character(len=col_width) :: basename(exe_target%output_file)] j = j + 1 end if |