From e546dfb7d5952abf8331cb9c1c9e687745fdf580 Mon Sep 17 00:00:00 2001 From: "init current directory[i]" Date: Fri, 9 Oct 2020 20:53:05 -0400 Subject: missing backfill implementation and only specifying --app on new subcommand --- fpm/src/fpm/cmd/new.f90 | 36 +++++++++++++++++++++++++----------- fpm/src/fpm_command_line.f90 | 18 +++++++++--------- 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/fpm/src/fpm/cmd/new.f90 b/fpm/src/fpm/cmd/new.f90 index 03d9ed4..0293033 100644 --- a/fpm/src/fpm/cmd/new.f90 +++ b/fpm/src/fpm/cmd/new.f90 @@ -16,7 +16,13 @@ character(len=:),allocatable :: bname ! baeename of NAME character(len=:),allocatable :: message(:) character(len=:),allocatable :: littlefile(:) - call mkdir(settings%name) ! make new directory + if(exists(settings%name) .and. .not.settings%backfill )then + write(stderr,'(*(g0,1x))')'fpm::new',settings%name,'already exists.' + write(stderr,'(*(g0,1x))')' perhaps you wanted to add --backfill ?' + return + else + call mkdir(settings%name) ! make new directory + endif call run('cd '//settings%name) ! change to new directory as a test. System dependent potentially !! NOTE: need some system routines to handle filenames like "." like realpath() or getcwd(). bname=basename(settings%name) @@ -89,17 +95,25 @@ character(len=:),allocatable :: littlefile(:) &'main="main.f90" ', & &''] - littlefile=[character(len=80) :: & - &'program main', & - &' use '//bname//', only: say_hello', & - &'', & - &' implicit none', & - &'', & - &' call say_hello', & - &'end program main'] + + if(exists(bname//'/src/'))then + littlefile=[character(len=80) :: & + &'program main', & + &' use '//bname//', only: say_hello', & + &' implicit none', & + &'', & + &' call say_hello()', & + &'end program main'] + else + littlefile=[character(len=80) :: & + &'program main', & + &' implicit none', & + &'', & + &' print *, "hello from project '//bname//'"', & + &'end program main'] + endif call warnwrite(join_path(settings%name, 'app/main.f90'), littlefile) endif - call warnwrite(join_path(settings%name, 'fpm.toml'), message) ! now that built it write NAME/fpm.toml call run('cd ' // settings%name // ';git init') ! assumes these commands work on all systems and git(1) is installed @@ -112,7 +126,7 @@ character(len=*),intent(in) :: data(:) if(.not.exists(fname))then call filewrite(fname,data) else - write(stderr,'(*(g0,1x))')'fpm::new',fname,'already exists. Not overwriting' + write(stderr,'(*(g0,1x))')'fpm::new',fname,'already exists. Not overwriting' endif end subroutine warnwrite diff --git a/fpm/src/fpm_command_line.f90 b/fpm/src/fpm_command_line.f90 index 502db99..fc76e05 100644 --- a/fpm/src/fpm_command_line.f90 +++ b/fpm/src/fpm_command_line.f90 @@ -123,7 +123,7 @@ contains & list=lget('list') ) case('new') - call set_args(' --lib F --app F --test F -backfill F', & + call set_args(' --lib F --app F --test F --backfill F', & & help_new, version_text) select case(size(unnamed)) case(1) @@ -364,10 +364,10 @@ contains ' fpm run ', & ' ', & ' # run a specific program and pass arguments to the command ', & - ' fpm run mytest -- -x 10 -y 20 -title "my title line" ', & + ' fpm run mytest -- -x 10 -y 20 --title "my title line" ', & ' ', & ' # production version of two applications ', & - ' fpm run tst1 test2 -release ', & + ' fpm run tst1 tst2 --release ', & 'SEE ALSO ', & ' The fpm(1) home page at https://github.com/fortran-lang/fpm ', & '' ] @@ -402,8 +402,8 @@ contains 'EXAMPLES ', & ' Sample commands: ', & ' ', & - ' fpm build # build with debug options ', & - ' fpm build -release # build with high optimization ', & + ' fpm build # build with debug options ', & + ' fpm build --release # build with high optimization ', & 'SEE ALSO ', & ' The fpm(1) home page at https://github.com/fortran-lang/fpm ', & '' ] @@ -509,8 +509,8 @@ contains ' option is present the directory may pre-exist and ', & ' only subdirectories and files that do not ', & ' already exist will be created. For example, if you ', & - ' previously entered "fpm new myname -lib" entering ', & - ' "fpm new myname -backfill" will create the missing ', & + ' previously entered "fpm new myname --lib" entering ', & + ' "fpm new myname --backfill" will create the missing', & ' app/ and test/ directories and missing programs. ', & ' ', & ' --help print this help and exit ', & @@ -560,9 +560,9 @@ contains ' fpm test ', & ' ', & ' # run a specific test and pass arguments to the command ', & - ' fpm test mytest -- -x 10 -y 20 -title "my title line" ', & + ' fpm test mytest -- -x 10 -y 20 --title "my title line" ', & ' ', & - ' fpm test tst1 test2 -release # production version of two tests', & + ' fpm test tst1 tst2 --release # production version of two tests', & 'SEE ALSO ', & ' The fpm(1) home page at https://github.com/fortran-lang/fpm ', & '' ] -- cgit v1.2.3