aboutsummaryrefslogtreecommitdiff
path: root/src/fpm_command_line.f90
diff options
context:
space:
mode:
authorurbanjost <urbanjost@comcast.net>2022-01-16 07:56:48 -0500
committerGitHub <noreply@github.com>2022-01-16 13:56:48 +0100
commit2ae0581eb2a8f79d0cd0ff9d528de6e2fe827362 (patch)
tree6ef3f238c980f16189260f4fe3095b30e6e8b341 /src/fpm_command_line.f90
parent64ce7b9da5826b3b728d470ae11994c23e234440 (diff)
downloadfpm-2ae0581eb2a8f79d0cd0ff9d528de6e2fe827362.tar.gz
fpm-2ae0581eb2a8f79d0cd0ff9d528de6e2fe827362.zip
Allow running fpm-new in current directory (#630)
Diffstat (limited to 'src/fpm_command_line.f90')
-rw-r--r--src/fpm_command_line.f9025
1 files changed, 20 insertions, 5 deletions
diff --git a/src/fpm_command_line.f90 b/src/fpm_command_line.f90
index 0837bf2..cb19192 100644
--- a/src/fpm_command_line.f90
+++ b/src/fpm_command_line.f90
@@ -31,10 +31,12 @@ use M_CLI2, only : get_subcommand, CLI_RESPONSE_FILE
use fpm_strings, only : lower, split, fnv_1a, to_fortran_name, is_fortran_name
use fpm_filesystem, only : basename, canon_path, which
use fpm_environment, only : run, get_command_arguments_quoted
-use fpm_error, only : fpm_stop
+use fpm_os, only : get_current_directory
+use fpm_error, only : fpm_stop, error_t
use,intrinsic :: iso_fortran_env, only : stdin=>input_unit, &
& stdout=>output_unit, &
& stderr=>error_unit
+
implicit none
private
@@ -179,6 +181,7 @@ contains
character(len=*), parameter :: fc_env = "FC", cc_env = "CC", ar_env = "AR", &
& fflags_env = "FFLAGS", cflags_env = "CFLAGS", ldflags_env = "LDFLAGS", &
& fc_default = "gfortran", cc_default = " ", ar_default = " ", flags_default = " "
+ type(error_t), allocatable :: error
call set_help()
! text for --version switch,
@@ -317,9 +320,13 @@ contains
& help_new, version_text)
select case(size(unnamed))
case(1)
- write(stderr,'(*(7x,g0,/))') &
- & '<USAGE> fpm new NAME [[--lib|--src] [--app] [--test] [--example]]|[--full|--bare] [--backfill]'
- call fpm_stop(1,'directory name required')
+ if(lget('backfill'))then
+ name='.'
+ else
+ write(stderr,'(*(7x,g0,/))') &
+ & '<USAGE> fpm new NAME [[--lib|--src] [--app] [--test] [--example]]|[--full|--bare] [--backfill]'
+ call fpm_stop(1,'directory name required')
+ endif
case(2)
name=trim(unnamed(2))
case default
@@ -328,6 +335,13 @@ contains
call fpm_stop(2,'only one directory name allowed')
end select
!*! canon_path is not converting ".", etc.
+ if(name.eq.'.')then
+ call get_current_directory(name, error)
+ if (allocated(error)) then
+ write(stderr, '("[Error]", 1x, a)') error%message
+ stop 1
+ endif
+ endif
name=canon_path(name)
if( .not.is_fortran_name(to_fortran_name(basename(name))) )then
write(stderr,'(g0)') [ character(len=72) :: &
@@ -336,6 +350,7 @@ contains
call fpm_stop(4,' ')
endif
+
allocate(fpm_new_settings :: cmd_settings)
if (any( specified([character(len=10) :: 'src','lib','app','test','example','bare'])) &
& .and.lget('full') )then
@@ -1079,7 +1094,7 @@ contains
' fpm new A --full # create example/ and an annotated fpm.toml as well', &
' fpm new A --bare # create no directories ', &
' create any missing files in current directory ', &
- ' fpm new `pwd` --full --backfill ', &
+ ' fpm new --full --backfill ', &
'' ]
help_test=[character(len=80) :: &
'NAME ', &