Execute a command and print pre/post status lines.
This routine is responsible for:
- Printing a "run" line (unless quiet),
- Executing the command via fpm_filesystem:run,
- Timing the execution with system_clock,
- Printing a final OK/FAIL summary and returning exitstat and secs.
When w%silent_fpm is true, the executed command's output is suppressed
(but the status lines from fpm-watch remain visible).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | cmd | |||
| type(watch_opts_t), | intent(in) | :: | w | |||
| integer, | intent(out) | :: | exitstat | |||
| real, | intent(out) | :: | secs |
subroutine run_command_and_report(cmd, w, exitstat, secs) character(len=*), intent(in) :: cmd type(watch_opts_t), intent(in) :: w integer, intent(out) :: exitstat real, intent(out) :: secs integer(int64) :: rate, t0, t1 logical :: verbose_run character(len=:), allocatable :: status_color character(len=:), allocatable :: status_word call system_clock(count_rate=rate) if (rate <= 0_int64) rate = 1000_int64 verbose_run = .not. w%silent_fpm if (w%verbosity >= 0) then if (w%silent_fpm) then write(output_unit,'(a)') & colorize("run |", color_fg='cyan_intense', style='bold_on') // " " // & colorize(trim(cmd), color_fg='white_intense') // " " // & colorize("(fpm output silenced)", color_fg='magenta_intense', style='italics_on') else write(output_unit,'(a)') & colorize("run |", color_fg='cyan_intense', style='bold_on') // " " // & colorize(trim(cmd), color_fg='white_intense') end if end if if (w%verbosity >= 0) flush(output_unit) call system_clock(t0) call run(trim(cmd), echo=.false., exitstat=exitstat, verbose=verbose_run) call system_clock(t1) secs = real(t1 - t0) / real(rate) if (exitstat == 0) then status_color = "green_intense" status_word = "OK" else status_color = "red_intense" status_word = "FAIL" end if if (w%verbosity >= 0) then write(output_unit,'(a)') "" write(output_unit,'(a)') & colorize("done |", color_fg=status_color, style='bold_on') // & " " // colorize(status_word, color_fg=status_color, style='bold_on') // & " exit=" // colorize(str(exitstat), color_fg=status_color, style='bold_on') // & " time=" // colorize(ftoa(secs), color_fg='yellow_intense') // "s" write(output_unit,'(a)') & colorize("command |", color_fg='cyan_intense', style='bold_on') // " " // & colorize(trim(cmd), color_fg='white_intense') write(output_unit,'(a)') & colorize("watch |", color_fg='cyan_intense', style='bold_on') // & " waiting (poll=" // colorize(ftoa(w%poll), color_fg='yellow') // "s" // & ", debounce=" // colorize(ftoa(w%debounce), color_fg='yellow') // "s) " // & colorize("Ctrl+C", color_fg='red_intense', style='bold_on') // " to stop" end if end subroutine run_command_and_report