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