@@ -2,7 +2,7 @@ module fpm_command_line
2
2
use fpm_environment, only : get_os_type, &
3
3
OS_UNKNOWN, OS_LINUX, OS_MACOS, OS_WINDOWS, &
4
4
OS_CYGWIN, OS_SOLARIS, OS_FREEBSD
5
- use M_CLI2, only : set_args, lget, unnamed, remaining, specified
5
+ use M_CLI2, only : set_args, lget, sget, unnamed, remaining, specified
6
6
use fpm_strings, only : lower
7
7
use fpm_filesystem, only : basename, canon_path
8
8
use ,intrinsic :: iso_fortran_env, only : stdin= >input_unit, &
@@ -39,6 +39,7 @@ module fpm_command_line
39
39
type, extends(fpm_build_settings) :: fpm_run_settings
40
40
character (len= ibug),allocatable :: name (:)
41
41
character (len= :),allocatable :: args
42
+ character (len= :),allocatable :: runner
42
43
end type
43
44
44
45
type, extends(fpm_run_settings) :: fpm_test_settings
@@ -57,6 +58,7 @@ module fpm_command_line
57
58
& help_text(:), help_install(:), help_help(:), &
58
59
& help_list(:), help_list_dash(:), help_list_nodash(:)
59
60
61
+ character (len= :), allocatable :: charbug
60
62
contains
61
63
subroutine get_command_line_settings (cmd_settings )
62
64
class(fpm_cmd_settings), allocatable , intent (out ) :: cmd_settings
@@ -97,7 +99,7 @@ subroutine get_command_line_settings(cmd_settings)
97
99
select case (trim (cmdarg))
98
100
99
101
case (' run' )
100
- call set_args(' --list F --release F --' ,help_run,version_text)
102
+ call set_args(' --list:l F --release:r F --runner:c " " --' ,help_run,version_text)
101
103
102
104
if ( size (unnamed) .gt. 1 )then
103
105
names= unnamed(2 :)
@@ -107,17 +109,17 @@ subroutine get_command_line_settings(cmd_settings)
107
109
108
110
allocate (fpm_run_settings :: cmd_settings)
109
111
cmd_settings= fpm_run_settings( name= names, list= lget(' list' ), &
110
- & release= lget(' release' ), args= remaining )
112
+ & release= lget(' release' ), args= remaining ,runner = sget( ' runner ' ) )
111
113
112
114
case (' build' )
113
- call set_args( ' --release F --list F --' ,help_build,version_text )
115
+ call set_args( ' --release:r F --list:l F --' ,help_build,version_text )
114
116
115
117
allocate ( fpm_build_settings :: cmd_settings )
116
118
cmd_settings= fpm_build_settings( release= lget(' release' ), &
117
119
& list= lget(' list' ) )
118
120
119
121
case (' new' )
120
- call set_args(' --src F --lib F --app F --test F --backfill F' , &
122
+ call set_args(' --src:s F --lib:l F --app:a F --test:t F --backfill:b F' , &
121
123
& help_new, version_text)
122
124
select case (size (unnamed))
123
125
case (1 )
@@ -203,17 +205,17 @@ subroutine get_command_line_settings(cmd_settings)
203
205
call printhelp(help_text)
204
206
205
207
case (' install' )
206
- call set_args(' --release F ' , help_install, version_text)
208
+ call set_args(' --release:r F ' , help_install, version_text)
207
209
208
210
allocate (fpm_install_settings :: cmd_settings)
209
211
case (' list' )
210
- call set_args(' --list F' , help_list, version_text)
212
+ call set_args(' --list:l F' , help_list, version_text)
211
213
call printhelp(help_list_nodash)
212
214
if (lget(' list' ))then
213
215
call printhelp(help_list_dash)
214
216
endif
215
217
case (' test' )
216
- call set_args(' --list F --release F --' ,help_test,version_text)
218
+ call set_args(' --list:l F --release:r F --runner:c " " --' ,help_test,version_text)
217
219
218
220
if ( size (unnamed) .gt. 1 )then
219
221
names= unnamed(2 :)
@@ -222,12 +224,13 @@ subroutine get_command_line_settings(cmd_settings)
222
224
endif
223
225
224
226
allocate (fpm_test_settings :: cmd_settings)
227
+ charbug= sget(' runner' )
225
228
cmd_settings= fpm_test_settings( name= names, list= lget(' list' ), &
226
- & release= lget(' release' ), args= remaining )
229
+ & release= lget(' release' ), args= remaining ,runner = charbug )
227
230
228
231
case default
229
232
230
- call set_args(' --list F' , help_fpm, version_text)
233
+ call set_args(' --list:l F' , help_fpm, version_text)
231
234
! Note: will not get here if --version or --usage or --help
232
235
! is present on commandline
233
236
help_text= help_usage
@@ -296,8 +299,8 @@ subroutine set_help()
296
299
' help [NAME(s)] ' , &
297
300
' new NAME [--lib|--src] [--app] [--test] [--backfill] ' , &
298
301
' list [--list] ' , &
299
- ' run [NAME(s)] [--release] [--list] [-- ARGS] ' , &
300
- ' test [NAME(s)] [--release] [--list] [-- ARGS] ' , &
302
+ ' run [NAME(s)] [--release] [--runner "CMD"] [-- list] [-- ARGS] ' , &
303
+ ' test [NAME(s)] [--release] [--runner "CMD"] [-- list] [-- ARGS] ' , &
301
304
' ' ]
302
305
help_usage= [character (len= 80 ) :: &
303
306
' ' ]
@@ -334,10 +337,10 @@ subroutine set_help()
334
337
' new NAME [--lib|--src] [--app] [--test] [--backfill] ' , &
335
338
' Create a new Fortran package directory ' , &
336
339
' with sample files ' , &
337
- ' run [NAME(s)] [--release] [--list] [-- ARGS] ' , &
340
+ ' run [NAME(s)] [--release] [--list] [--runner "CMD"][-- ARGS] ' , &
338
341
' Run the local package binaries. defaults to all ' , &
339
342
' binaries for that release. ' , &
340
- ' test [NAME(s)] [--release] [--list] [-- ARGS] ' , &
343
+ ' test [NAME(s)] [--release] [--list] [--runner "CMD"] [-- ARGS] ' , &
341
344
' Run the tests ' , &
342
345
' help [NAME(s)] Alternate method for displaying subcommand help ' , &
343
346
' list [--list] Display brief descriptions of all subcommands. ' , &
@@ -350,6 +353,7 @@ subroutine set_help()
350
353
' optimization flags are used. ' , &
351
354
' --list List candidates instead of building or running them. On ' , &
352
355
' the fpm(1) command this shows a brief list of subcommands.' , &
356
+ ' --runner CMD Provides a command to prefix program execution paths. ' , &
353
357
' -- ARGS Arguments to pass to executables. ' , &
354
358
' --help Show help text and exit. Valid for all subcommands. ' , &
355
359
' --version Show version information and exit. Valid for all ' , &
@@ -398,7 +402,7 @@ subroutine set_help()
398
402
' run(1) - the fpm(1) subcommand to run project applications ' , &
399
403
' ' , &
400
404
' SYNOPSIS ' , &
401
- ' fpm run [NAME(s)] [--release] [-- ARGS] ' , &
405
+ ' fpm run [NAME(s)] [--release] [--runner "CMD"] [-- ARGS] ' , &
402
406
' ' , &
403
407
' fpm run --help|--version ' , &
404
408
' ' , &
@@ -412,12 +416,18 @@ subroutine set_help()
412
416
' --release selects the optimized build instead of the debug ' , &
413
417
' build. ' , &
414
418
' --list list candidates instead of building or running them ' , &
419
+ ' --runner CMD A command to prefix the program execution paths with. ' , &
420
+ ' For use with utilities like valgrind(1), time(1), and ' , &
421
+ ' other utilities that launch executables; commands that ' , &
422
+ ' inspect the files like ldd(1), file(1), and ls(1); and ' , &
423
+ ' ones that copy or change files like strip(1) and ' , &
424
+ ' install(1). ' , &
415
425
' -- ARGS optional arguments to pass to the program(s). ' , &
416
426
' The same arguments are passed to all names ' , &
417
427
' specified. ' , &
418
428
' ' , &
419
429
' EXAMPLES ' , &
420
- ' run fpm(1) project applications ' , &
430
+ ' fpm(1) "run" project applications ' , &
421
431
' ' , &
422
432
' # run default programs in /app or as specified in "fpm.toml" ' , &
423
433
' fpm run ' , &
@@ -428,6 +438,9 @@ subroutine set_help()
428
438
' # run production version of two applications ' , &
429
439
' fpm run prg1 prg2 --release ' , &
430
440
' ' , &
441
+ ' # install executables in directory (assuming install(1) exists) ' , &
442
+ ' fpm run -c '' install -b -m 0711 -p -t /usr/local/bin'' ' , &
443
+ ' ' , &
431
444
' SEE ALSO ' , &
432
445
' The fpm(1) home page at https://github.com/fortran-lang/fpm ' , &
433
446
' ' ]
@@ -589,7 +602,7 @@ subroutine set_help()
589
602
' test(1) - the fpm(1) subcommand to run project tests ' , &
590
603
' ' , &
591
604
' SYNOPSIS ' , &
592
- ' fpm test [NAME(s)] [--release] [--list] [-- ARGS] ' , &
605
+ ' fpm test [NAME(s)] [--release] [--list] [--runner "CMD"] [-- ARGS] ' , &
593
606
' ' , &
594
607
' fpm test --help|--version ' , &
595
608
' ' , &
@@ -603,6 +616,12 @@ subroutine set_help()
603
616
' --release selects the optimized build instead of the debug ' , &
604
617
' build. ' , &
605
618
' --list list candidates instead of building or running them ' , &
619
+ ' --runner CMD A command to prefix the program execution paths with. ' , &
620
+ ' For use with utilities like valgrind(1), time(1), and ' , &
621
+ ' other utilities that launch executables; commands that ' , &
622
+ ' inspect the files like ldd(1), file(1), and ls(1); and ' , &
623
+ ' ones that copy or change files like strip(1) and ' , &
624
+ ' install(1). ' , &
606
625
' -- ARGS optional arguments to pass to the test program(s). ' , &
607
626
' The same arguments are passed to all test names ' , &
608
627
' specified. ' , &
0 commit comments