Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In the default case of command line subcommands, stop fpm running in time #728

Merged
merged 1 commit into from
Sep 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/fpm.f90
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module fpm
fpm_clean_settings
use fpm_dependency, only : new_dependency_tree
use fpm_environment, only: get_env
use fpm_filesystem, only: is_dir, join_path, number_of_rows, list_files, exists, &
use fpm_filesystem, only: is_dir, join_path, list_files, exists, &
basename, filewrite, mkdir, run, os_delete_dir
use fpm_model, only: fpm_model_t, srcfile_t, show_model, &
FPM_SCOPE_UNKNOWN, FPM_SCOPE_LIB, FPM_SCOPE_DEP, &
Expand Down
19 changes: 11 additions & 8 deletions src/fpm_command_line.f90
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,9 @@ module fpm_command_line
subroutine get_command_line_settings(cmd_settings)
class(fpm_cmd_settings), allocatable, intent(out) :: cmd_settings

integer, parameter :: widest = 256
character(len=4096) :: cmdarg
integer :: i
integer :: widest
integer :: os
logical :: unix
type(fpm_install_settings), allocatable :: install_settings
Expand Down Expand Up @@ -423,7 +423,6 @@ subroutine get_command_line_settings(cmd_settings)
elseif(unnamed(2)=='manual')then
unnamed=manual
endif
widest=256
allocate(character(len=widest) :: help_text(0))
do i=2,size(unnamed)
select case(unnamed(i))
Expand Down Expand Up @@ -494,10 +493,12 @@ subroutine get_command_line_settings(cmd_settings)
call set_args(common_args // '&
& --list F&
&', help_list, version_text)
call printhelp(help_list_nodash)
if(lget('list'))then
call printhelp(help_list_dash)
help_text = [character(widest) :: help_list_nodash, help_list_dash]
else
help_text = help_list_nodash
endif
call printhelp(help_text)

case('test')
call set_args(common_args // compiler_args // run_args // ' --', &
Expand Down Expand Up @@ -576,23 +577,23 @@ subroutine get_command_line_settings(cmd_settings)

if(cmdarg.ne.''.and.which('fpm-'//cmdarg).ne.'')then
call run('fpm-'//trim(cmdarg)//' '// get_command_arguments_quoted(),.false.)
stop
else
call set_args('&
& --list F&
&', help_fpm, version_text)
! Note: will not get here if --version or --usage or --help
! is present on commandline
help_text=help_usage
if(lget('list'))then
help_text=help_list_dash
help_text = help_list_dash
elseif(len_trim(cmdarg)==0)then
write(stdout,'(*(a))')'Fortran Package Manager:'
write(stdout,'(*(a))')' '
call printhelp(help_list_nodash)
help_text = [character(widest) :: help_list_nodash, help_usage]
else
write(stderr,'(*(a))')'<ERROR> unknown subcommand [', &
& trim(cmdarg), ']'
call printhelp(help_list_dash)
help_text = [character(widest) :: help_list_dash, help_usage]
endif
call printhelp(help_text)
endif
Expand Down Expand Up @@ -621,6 +622,7 @@ subroutine check_build_vals()

end subroutine check_build_vals

!> Print help text and stop
subroutine printhelp(lines)
character(len=:),intent(in),allocatable :: lines(:)
integer :: iii,ii
Expand All @@ -632,6 +634,7 @@ subroutine printhelp(lines)
write(stdout,'(a)')'<WARNING> *printhelp* output requested is empty'
endif
endif
stop
end subroutine printhelp

end subroutine get_command_line_settings
Expand Down