From 71bd548ca237675348ac25b622f1896898cd078d Mon Sep 17 00:00:00 2001 From: milancurcic Date: Fri, 24 Jul 2020 12:23:50 -0400 Subject: use select case and trim cmdarg --- fpm/app/main.f90 | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/fpm/app/main.f90 b/fpm/app/main.f90 index 8533f8c..ad1a9e0 100644 --- a/fpm/app/main.f90 +++ b/fpm/app/main.f90 @@ -7,12 +7,13 @@ if (command_argument_count() == 0) then call print_help() else if (command_argument_count() == 1) then call get_command_argument(1, cmdarg) - if (cmdarg == "build") then - call cmd_build() - else - print *, "Unknown command: ", cmdarg - error stop - end if + select case(trim(cmdarg)) + case("build") + call cmd_build() + case default + print *, "Unknown command: ", cmdarg + error stop + end select else print *, "Too many arguments" error stop -- cgit v1.2.3 From 186b0c47300d2e6d4ef39e8c77dca30c71b3ffb1 Mon Sep 17 00:00:00 2001 From: milancurcic Date: Fri, 24 Jul 2020 12:37:07 -0400 Subject: add placeholder commands and not-implemented notes --- fpm/app/main.f90 | 12 +++++++++--- fpm/src/fpm.f90 | 18 +++++++++++++++++- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/fpm/app/main.f90 b/fpm/app/main.f90 index ad1a9e0..47d7cb1 100644 --- a/fpm/app/main.f90 +++ b/fpm/app/main.f90 @@ -1,5 +1,5 @@ program main -use fpm, only: print_help, cmd_build +use fpm, only: print_help, cmd_build, cmd_install, cmd_new, cmd_run, cmd_test implicit none character(100) :: cmdarg @@ -10,9 +10,15 @@ else if (command_argument_count() == 1) then select case(trim(cmdarg)) case("build") call cmd_build() + case("install") + call cmd_install() + case("new") + call cmd_new() + case("run") + call cmd_run() case default - print *, "Unknown command: ", cmdarg - error stop + print *, "Unknown command: " // trim(cmdarg) + call print_help() end select else print *, "Too many arguments" diff --git a/fpm/src/fpm.f90 b/fpm/src/fpm.f90 index bd1a70e..bfb31fc 100644 --- a/fpm/src/fpm.f90 +++ b/fpm/src/fpm.f90 @@ -1,7 +1,7 @@ module fpm implicit none private -public :: print_help, cmd_build +public :: print_help, cmd_build, cmd_install, cmd_new, cmd_run, cmd_test integer, parameter :: OS_LINUX = 1 integer, parameter :: OS_MACOS = 2 @@ -174,4 +174,20 @@ call package_name(pkg_name) call run("gfortran main.o " // linking // " -o " // pkg_name) end subroutine +subroutine cmd_install() + print *, "fpm error: 'fpm install' not implemented." +end subroutine + +subroutine cmd_new() + print *, "fpm error: 'fpm new' not implemented." +end subroutine + +subroutine cmd_run() + print *, "fpm error: 'fpm run' not implemented." +end subroutine + +subroutine cmd_test() + print *, "fpm error: 'fpm test' not implemented." +end subroutine + end module fpm -- cgit v1.2.3 From 81bd372d35456008ac367c0a9502b9f7e9616bc3 Mon Sep 17 00:00:00 2001 From: milancurcic Date: Fri, 24 Jul 2020 12:47:14 -0400 Subject: expand the help message with command list and description --- fpm/src/fpm.f90 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/fpm/src/fpm.f90 b/fpm/src/fpm.f90 index bfb31fc..fe3079b 100644 --- a/fpm/src/fpm.f90 +++ b/fpm/src/fpm.f90 @@ -114,6 +114,16 @@ select case (get_os_type()) case (OS_WINDOWS) print *, "OS Type: Windows" end select +print * +print *, "USAGE:" +print *, " fpm [COMMAND]" +print * +print *, "Valid fpm commands are:" +print *, " build Compile the current package" +print *, " install Install a Fortran binary or library (not implemented)" +print *, " new Create a new Fortran package (not implemented)" +print *, " run Run a binary of the local package (not implemented)" +print *, " test Run the tests (not implemented)" end subroutine subroutine run(cmd) -- cgit v1.2.3 From be4d958403d8a379b8360f5f5a7d3f9e34e1aaec Mon Sep 17 00:00:00 2001 From: milancurcic Date: Fri, 24 Jul 2020 12:47:44 -0400 Subject: revert to erroring on unknown command to be more consistent with Cargo UI --- fpm/app/main.f90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fpm/app/main.f90 b/fpm/app/main.f90 index 47d7cb1..55c22fd 100644 --- a/fpm/app/main.f90 +++ b/fpm/app/main.f90 @@ -17,8 +17,8 @@ else if (command_argument_count() == 1) then case("run") call cmd_run() case default - print *, "Unknown command: " // trim(cmdarg) - call print_help() + print *, "fpm error: No such command " // trim(cmdarg) + error stop end select else print *, "Too many arguments" -- cgit v1.2.3 From 53b06aadcdf5b527d2df02e2a532c6257acceb22 Mon Sep 17 00:00:00 2001 From: milancurcic Date: Fri, 24 Jul 2020 12:53:16 -0400 Subject: drop uppercase USAGE and more descriptive tagline --- fpm/src/fpm.f90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fpm/src/fpm.f90 b/fpm/src/fpm.f90 index fe3079b..d04a62a 100644 --- a/fpm/src/fpm.f90 +++ b/fpm/src/fpm.f90 @@ -105,7 +105,7 @@ close(u) end subroutine subroutine print_help() -print *, "Fortran Package Manager (fpm)" +print *, "fpm - A Fortran package manager and build system" select case (get_os_type()) case (OS_LINUX) print *, "OS Type: Linux" @@ -115,7 +115,7 @@ select case (get_os_type()) print *, "OS Type: Windows" end select print * -print *, "USAGE:" +print *, "Usage:" print *, " fpm [COMMAND]" print * print *, "Valid fpm commands are:" -- cgit v1.2.3 From 0bbf28260688525fdd1a6d6b3476077965e5d80f Mon Sep 17 00:00:00 2001 From: milancurcic Date: Fri, 24 Jul 2020 13:22:45 -0400 Subject: error stop in not implemented command subroutines; add exit code to error stop --- fpm/app/main.f90 | 4 ++-- fpm/src/fpm.f90 | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/fpm/app/main.f90 b/fpm/app/main.f90 index 55c22fd..361cae5 100644 --- a/fpm/app/main.f90 +++ b/fpm/app/main.f90 @@ -18,10 +18,10 @@ else if (command_argument_count() == 1) then call cmd_run() case default print *, "fpm error: No such command " // trim(cmdarg) - error stop + error stop 1 end select else print *, "Too many arguments" - error stop + error stop 1 end if end program main diff --git a/fpm/src/fpm.f90 b/fpm/src/fpm.f90 index d04a62a..aefbfd0 100644 --- a/fpm/src/fpm.f90 +++ b/fpm/src/fpm.f90 @@ -186,18 +186,22 @@ end subroutine subroutine cmd_install() print *, "fpm error: 'fpm install' not implemented." + error stop 1 end subroutine subroutine cmd_new() print *, "fpm error: 'fpm new' not implemented." + error stop 1 end subroutine subroutine cmd_run() print *, "fpm error: 'fpm run' not implemented." + error stop 1 end subroutine subroutine cmd_test() print *, "fpm error: 'fpm test' not implemented." + error stop 1 end subroutine end module fpm -- cgit v1.2.3