diff options
-rw-r--r-- | fpm/src/fpm/cmd/new.f90 | 49 | ||||
-rw-r--r-- | fpm/src/fpm_command_line.f90 | 16 | ||||
-rw-r--r-- | fpm/test/new_test/new_test.f90 | 14 |
3 files changed, 39 insertions, 40 deletions
diff --git a/fpm/src/fpm/cmd/new.f90 b/fpm/src/fpm/cmd/new.f90 index abfc642..2435eb3 100644 --- a/fpm/src/fpm/cmd/new.f90 +++ b/fpm/src/fpm/cmd/new.f90 @@ -3,49 +3,49 @@ module fpm_cmd_new !> !> A type of the general command base class [[fpm_cmd_settings]] !> was created for the "new" subcommand ==> type [[fpm_new_settings]]. -!> This procedure read the values that were set on the command line -!> from this type to decide what actions to take. +!> This procedure read the values that were set on the command line +!> from this type to decide what actions to take. !> -!> It is virtually self-contained and so independant of the rest of the -!> application that it could function as a seperate program. +!> It is virtually self-contained and so independant of the rest of the +!> application that it could function as a seperate program. !> !> The "new" subcommand options currently consist of a SINGLE top -!> directory name to create that must have a name that is an +!> directory name to create that must have a name that is an !> allowable Fortran variable name. That should have been ensured !> by the command line processing before this procedure is called. !> So basically this routine has already had the options vetted and !> just needs to conditionally create a few files. -!> +!> !> As described in the documentation documentation it will selectively !> create the subdirectories app/, test/, src/, and example/ !> and populate them with sample files. -!> +!> !> It also needs to create an initial manifest file "fpm.toml". -!> +!> !> It then calls the system command "git init". !> !> It should test for file existence and not overwrite existing -!> files and inform the user if there were conflicts. +!> files and inform the user if there were conflicts. !> !> Any changes should be reflected in the documentation in !> [[fpm_command_line.f90]] -!> +!> !> FUTURE !> A filename like "." would need system commands or a standard routine !> like realpath(3c) to process properly. -!> +!> !> Perhaps allow more than one name on a single command. It is an arbitrary !> restriction based on a concensus preference, not a required limitation. -!> +!> !> Initially the name of the directory is used as the module name in the !> src file so it must be an allowable Fortran variable name. If there are !> complaints about it it might be changed. Handling unicode at this point -!> might be problematic as not all current compilers handle it. Other +!> might be problematic as not all current compilers handle it. Other !> utilities like content trackers (ie. git) or repositories like github !> might also have issues with alternative names or names with spaces, etc. !> So for the time being it seems prudent to encourage simple ASCII top directory !> names (similiar to the primary programming language Fortran itself). -!> +!> !> Should be able to create or pull more complicated initial examples !> based on various templates. It should place or mention other relevant !> documents such as a description of the manifest file format in user hands; @@ -92,8 +92,7 @@ character(len=8) :: date call mkdir(settings%name) endif - - !> temporarily change to new directory as a test. NB: System dependent + !> temporarily change to new directory as a test. NB: System dependent call run('cd '//settings%name) ! NOTE: need some system routines to handle filenames like "." ! like realpath() or getcwd(). @@ -151,17 +150,17 @@ character(len=8) :: date &'[[test]] ', & &'name="runTests" ', & &'source-dir="test" ', & - &'main="main.f90" ', & + &'main="check.f90" ', & &''] littlefile=[character(len=80) :: & - &'program main', & + &'program check', & &'implicit none', & &'', & &'print *, "Put some tests in here!"', & - &'end program main'] - ! create NAME/test/main.f90 - call warnwrite(join_path(settings%name, 'test/main.f90'), littlefile) + &'end program check'] + ! create NAME/test/check.f90 + call warnwrite(join_path(settings%name, 'test/check.f90'), littlefile) endif if(settings%with_example)then @@ -229,7 +228,7 @@ character(len=*),intent(in) :: data(:) if(.not.exists(fname))then call filewrite(fname,data) else - write(stderr,'(*(g0,1x))')'INFO: ',fname,& + write(stderr,'(*(g0,1x))')'<INFO> ',fname,& & 'already exists. Not overwriting' endif @@ -263,7 +262,7 @@ character(len=256) :: message endif if(ios.ne.0)then write(stderr,'(*(a:,1x))')& - & '*filewrite* error:',filename,trim(message) + & '<ERROR> *filewrite*:',filename,trim(message) error stop 1 endif ! write file @@ -271,14 +270,14 @@ character(len=256) :: message write(lun,'(a)',iostat=ios,iomsg=message)trim(filedata(i)) if(ios.ne.0)then write(stderr,'(*(a:,1x))')& - & '*filewrite* error:',filename,trim(message) + & '<ERROR> *filewrite*:',filename,trim(message) error stop 4 endif enddo ! close file close(unit=lun,iostat=ios,iomsg=message) if(ios.ne.0)then - write(stderr,'(*(a:,1x))')'*filewrite* error:',trim(message) + write(stderr,'(*(a:,1x))')'<ERROR> *filewrite*:',trim(message) error stop 2 endif end subroutine filewrite diff --git a/fpm/src/fpm_command_line.f90 b/fpm/src/fpm_command_line.f90 index 87b80b9..6e9a5bd 100644 --- a/fpm/src/fpm_command_line.f90 +++ b/fpm/src/fpm_command_line.f90 @@ -135,10 +135,10 @@ contains & os_type] ! find the subcommand name by looking for first word on command ! not starting with dash - cmdarg = '' + cmdarg=' ' do i = 1, command_argument_count() - call get_command_argument(i, cmdarg) - if(adjustl(cmdarg(1:1)) .ne. '-')exit + call get_command_argument(i, cmdarg) + if(adjustl(cmdarg(1:1)) .ne. '-')exit enddo ! now set subcommand-specific help text and process commandline @@ -252,7 +252,7 @@ contains & with_executable=.true., & & with_lib=.true., & & with_test=.true., & - & with_example=.true., & + & with_example=.false., & & verbose=lget('verbose') ) endif @@ -819,7 +819,7 @@ contains ' app/ ', & ' main.f90 ', & ' test/ ', & - ' main.f90 ', & + ' check.f90 ', & ' example/ ', & ' demo.f90 ', & ' ', & @@ -832,7 +832,7 @@ contains ' ASCII alphanumeric characters and underscores, ', & ' starting with a letter. ', & ' ', & - ' The default is to create all of the src/, app/, test/, and example/ ', & + ' The default is to create the src/, app/, and test/, ', & ' directories. If any of the following options are specified ', & ' then only selected subdirectories are generated: ', & ' ', & @@ -846,7 +846,7 @@ contains ' --example create directory example/ and a placeholder program ', & ' for use with the subcommand "run --example". ', & ' ', & - ' So the default is equivalent to "fpm NAME --lib --app --test --example" ', & + ' So the default is equivalent to "fpm NAME --lib --app --test" ', & ' ', & ' --backfill By default the directory must not exist. If this ', & ' option is present the directory may pre-exist and ', & @@ -854,7 +854,7 @@ contains ' already exist will be created. For example, if you ', & ' previously entered "fpm new myname --lib" entering ', & ' "fpm new myname --backfill" will create the missing ', & - ' app/, test/ and example/ directories and programs. ', & + ' app/ and test/ directories and programs. ', & ' ', & ' --help print this help and exit ', & ' --version print program version information and exit ', & diff --git a/fpm/test/new_test/new_test.f90 b/fpm/test/new_test/new_test.f90 index 2dfc11e..22cf113 100644 --- a/fpm/test/new_test/new_test.f90 +++ b/fpm/test/new_test/new_test.f90 @@ -92,25 +92,25 @@ logical :: IS_OS_WINDOWS else select case(shortdirs(i)) case('A'); expected=[ character(len=80)::& - &'A/app','A/fpm.toml','A/README.md','A/src','A/test','A/app/main.f90','A/src/'//scr//'A.f90','A/test/main.f90'] + &'A/app','A/fpm.toml','A/README.md','A/src','A/test','A/app/main.f90','A/src/'//scr//'A.f90','A/test/check.f90'] case('B'); expected=[ character(len=80)::& &'B/fpm.toml','B/README.md','B/src','B/src/'//scr//'B.f90'] case('C'); expected=[ character(len=80)::& &'C/app','C/fpm.toml','C/README.md','C/app/main.f90'] case('D'); expected=[ character(len=80)::& - &'D/fpm.toml','D/README.md','D/test','D/test/main.f90'] + &'D/fpm.toml','D/README.md','D/test','D/test/check.f90'] case('E'); expected=[ character(len=80)::& - &'E/fpm.toml','E/README.md','E/src','E/test','E/src/'//scr//'E.f90','E/test/main.f90'] + &'E/fpm.toml','E/README.md','E/src','E/test','E/src/'//scr//'E.f90','E/test/check.f90'] case('F'); expected=[ character(len=80)::& &'F/app','F/fpm.toml','F/README.md','F/src','F/app/main.f90','F/src/'//scr//'F.f90'] case('G'); expected=[ character(len=80)::& - &'G/app','G/fpm.toml','G/README.md','G/test','G/app/main.f90','G/test/main.f90'] + &'G/app','G/fpm.toml','G/README.md','G/test','G/app/main.f90','G/test/check.f90'] case('H'); expected=[ character(len=80)::& &'H/example','H/fpm.toml','H/README.md','H/example/demo.f90'] case('BB'); expected=[ character(len=80)::& - &'BB/fpm.toml','BB/README.md','BB/src','BB/test','BB/src/'//scr//'BB.f90','BB/test/main.f90'] + &'BB/fpm.toml','BB/README.md','BB/src','BB/test','BB/src/'//scr//'BB.f90','BB/test/check.f90'] case('CC'); expected=[ character(len=80)::& - &'CC/app','CC/fpm.toml','CC/README.md','CC/src','CC/test','CC/app/main.f90','CC/src/'//scr//'CC.f90','CC/test/main.f90'] + &'CC/app','CC/fpm.toml','CC/README.md','CC/src','CC/test','CC/app/main.f90','CC/src/'//scr//'CC.f90','CC/test/check.f90'] case default write(*,*)'ERROR: internal error. unknown directory name ',trim(shortdirs(i)) stop 4 @@ -149,7 +149,7 @@ logical :: IS_OS_WINDOWS call execute_command_line('rmdir fpm_scratch_* /s /q',exitstat=estat,cmdstat=cstat,cmdmsg=message) end select - write(*,'("TALLY=",*(g0))')tally + write(*,'("new TEST TALLY=",*(g0))')tally if(all(tally))then write(*,'(*(g0))')'PASSED: all ',count(tally),' tests passed ' else |