@@ -31,10 +31,12 @@ module fpm_command_line
31
31
use fpm_strings, only : lower, split, fnv_1a, to_fortran_name, is_fortran_name
32
32
use fpm_filesystem, only : basename, canon_path, which
33
33
use fpm_environment, only : run, get_command_arguments_quoted
34
- use fpm_error, only : fpm_stop
34
+ use fpm_os, only : get_current_directory
35
+ use fpm_error, only : fpm_stop, error_t
35
36
use ,intrinsic :: iso_fortran_env, only : stdin= >input_unit, &
36
37
& stdout= >output_unit, &
37
38
& stderr= >error_unit
39
+
38
40
implicit none
39
41
40
42
private
@@ -179,6 +181,7 @@ subroutine get_command_line_settings(cmd_settings)
179
181
character (len=* ), parameter :: fc_env = " FC" , cc_env = " CC" , ar_env = " AR" , &
180
182
& fflags_env = " FFLAGS" , cflags_env = " CFLAGS" , ldflags_env = " LDFLAGS" , &
181
183
& fc_default = " gfortran" , cc_default = " " , ar_default = " " , flags_default = " "
184
+ type (error_t), allocatable :: error
182
185
183
186
call set_help()
184
187
! text for --version switch,
@@ -317,9 +320,13 @@ subroutine get_command_line_settings(cmd_settings)
317
320
& help_new, version_text)
318
321
select case (size (unnamed))
319
322
case (1 )
320
- write (stderr,' (*(7x,g0,/))' ) &
321
- & ' <USAGE> fpm new NAME [[--lib|--src] [--app] [--test] [--example]]|[--full|--bare] [--backfill]'
322
- call fpm_stop(1 ,' directory name required' )
323
+ if (lget(' backfill' ))then
324
+ name= ' .'
325
+ else
326
+ write (stderr,' (*(7x,g0,/))' ) &
327
+ & ' <USAGE> fpm new NAME [[--lib|--src] [--app] [--test] [--example]]|[--full|--bare] [--backfill]'
328
+ call fpm_stop(1 ,' directory name required' )
329
+ endif
323
330
case (2 )
324
331
name= trim (unnamed(2 ))
325
332
case default
@@ -328,6 +335,13 @@ subroutine get_command_line_settings(cmd_settings)
328
335
call fpm_stop(2 ,' only one directory name allowed' )
329
336
end select
330
337
! *! canon_path is not converting ".", etc.
338
+ if (name.eq. ' .' )then
339
+ call get_current_directory(name, error)
340
+ if (allocated (error)) then
341
+ write (stderr, ' ("[Error]", 1x, a)' ) error% message
342
+ stop 1
343
+ endif
344
+ endif
331
345
name= canon_path(name)
332
346
if ( .not. is_fortran_name(to_fortran_name(basename(name))) )then
333
347
write (stderr,' (g0)' ) [ character (len= 72 ) :: &
@@ -336,6 +350,7 @@ subroutine get_command_line_settings(cmd_settings)
336
350
call fpm_stop(4 ,' ' )
337
351
endif
338
352
353
+
339
354
allocate (fpm_new_settings :: cmd_settings)
340
355
if (any ( specified([character (len= 10 ) :: ' src' ,' lib' ,' app' ,' test' ,' example' ,' bare' ])) &
341
356
& .and. lget(' full' ) )then
@@ -1079,7 +1094,7 @@ subroutine set_help()
1079
1094
' fpm new A --full # create example/ and an annotated fpm.toml as well' , &
1080
1095
' fpm new A --bare # create no directories ' , &
1081
1096
' create any missing files in current directory ' , &
1082
- ' fpm new `pwd` --full --backfill ' , &
1097
+ ' fpm new --full --backfill ' , &
1083
1098
' ' ]
1084
1099
help_test= [character (len= 80 ) :: &
1085
1100
' NAME ' , &
0 commit comments