Skip to content

Commit e15996c

Browse files
committed
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.
1 parent 5aa571c commit e15996c

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

fpm/src/fpm.f90

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,8 @@ subroutine cmd_run(settings,test)
304304
class(fpm_run_settings), intent(in) :: settings
305305
logical, intent(in) :: test
306306

307-
integer :: i, j
307+
integer, parameter :: LINE_WIDTH = 80
308+
integer :: i, j, col_width, nCol
308309
logical :: found(size(settings%name))
309310
type(error_t), allocatable :: error
310311
type(package_t) :: package
@@ -329,6 +330,7 @@ subroutine cmd_run(settings,test)
329330
end if
330331

331332
! Enumerate executable targets to run
333+
col_width = 10
332334
found(:) = .false.
333335
allocate(executables(0))
334336
do i=1,size(model%targets)
@@ -343,6 +345,8 @@ subroutine cmd_run(settings,test)
343345
if (exe_source%unit_scope == &
344346
merge(FPM_SCOPE_TEST,FPM_SCOPE_APP,test)) then
345347

348+
col_width = max(col_width,len(basename(exe_target%output_file))+2)
349+
346350
if (size(settings%name) == 0) then
347351

348352
exe_cmd%s = exe_target%output_file
@@ -381,6 +385,7 @@ subroutine cmd_run(settings,test)
381385
write(stderr,*)
382386

383387
j = 1
388+
nCol = LINE_WIDTH/col_width
384389
write(stderr,*) 'Available names:'
385390
do i=1,size(model%targets)
386391

@@ -394,8 +399,8 @@ subroutine cmd_run(settings,test)
394399
if (exe_source%unit_scope == &
395400
merge(FPM_SCOPE_TEST,FPM_SCOPE_APP,test)) then
396401

397-
write(stderr,'(A17)',advance=(merge("yes","no ",modulo(j,4)==0))) basename(exe_target%output_file)
398-
402+
write(stderr,'(A)',advance=(merge("yes","no ",modulo(j,nCol)==0))) &
403+
& [character(len=col_width) :: basename(exe_target%output_file)]
399404
j = j + 1
400405

401406
end if

0 commit comments

Comments
 (0)