23
23
! > ``fpm-help`` and ``fpm --list`` help pages below to make sure the help output
24
24
! > is complete and consistent as well.
25
25
module fpm_command_line
26
- use fpm_environment, only : get_os_type, get_env, &
26
+ use fpm_environment, only : get_os_type, get_env, os_is_unix, &
27
27
OS_UNKNOWN, OS_LINUX, OS_MACOS, OS_WINDOWS, &
28
28
OS_CYGWIN, OS_SOLARIS, OS_FREEBSD, OS_OPENBSD
29
29
use M_CLI2, only : set_args, lget, sget, unnamed, remaining, specified
@@ -47,6 +47,7 @@ module fpm_command_line
47
47
fpm_run_settings, &
48
48
fpm_test_settings, &
49
49
fpm_update_settings, &
50
+ fpm_clean_settings, &
50
51
get_command_line_settings
51
52
52
53
type, abstract :: fpm_cmd_settings
@@ -104,6 +105,10 @@ module fpm_command_line
104
105
logical :: clean
105
106
end type
106
107
108
+ type, extends(fpm_cmd_settings) :: fpm_clean_settings
109
+ logical :: unix
110
+ end type
111
+
107
112
character (len= :),allocatable :: name
108
113
character (len= :),allocatable :: os_type
109
114
character (len= ibug),allocatable :: names(:)
@@ -113,9 +118,10 @@ module fpm_command_line
113
118
character (len= :), allocatable :: help_new(:), help_fpm(:), help_run(:), &
114
119
& help_test(:), help_build(:), help_usage(:), help_runner(:), &
115
120
& help_text(:), help_install(:), help_help(:), help_update(:), &
116
- & help_list(:), help_list_dash(:), help_list_nodash(:)
121
+ & help_list(:), help_list_dash(:), help_list_nodash(:), &
122
+ & help_clean(:)
117
123
character (len= 20 ),parameter :: manual(* )= [ character (len= 20 ) :: &
118
- & ' ' , ' fpm' , ' new' , ' build' , ' run' , &
124
+ & ' ' , ' fpm' , ' new' , ' build' , ' run' , ' clean ' , &
119
125
& ' test' , ' runner' , ' install' , ' update' , ' list' , ' help' , ' version' ]
120
126
121
127
character (len= :), allocatable :: val_runner, val_compiler, val_flag, val_cflag, val_ldflag, &
@@ -174,6 +180,8 @@ subroutine get_command_line_settings(cmd_settings)
174
180
character (len= 4096 ) :: cmdarg
175
181
integer :: i
176
182
integer :: widest
183
+ integer :: os
184
+ logical :: unix
177
185
type (fpm_install_settings), allocatable :: install_settings
178
186
character (len= :), allocatable :: common_args, compiler_args, run_args, working_dir, &
179
187
& c_compiler, archiver
@@ -184,8 +192,9 @@ subroutine get_command_line_settings(cmd_settings)
184
192
type (error_t), allocatable :: error
185
193
186
194
call set_help()
195
+ os = get_os_type()
187
196
! text for --version switch,
188
- select case (get_os_type() )
197
+ select case (os )
189
198
case (OS_LINUX); os_type = " OS Type: Linux"
190
199
case (OS_MACOS); os_type = " OS Type: macOS"
191
200
case (OS_WINDOWS); os_type = " OS Type: Windows"
@@ -196,6 +205,7 @@ subroutine get_command_line_settings(cmd_settings)
196
205
case (OS_UNKNOWN); os_type = " OS Type: Unknown"
197
206
case default ; os_type = " OS Type: UNKNOWN"
198
207
end select
208
+ unix = os_is_unix(os)
199
209
version_text = [character (len= 80 ) :: &
200
210
& ' Version: 0.5.0, alpha' , &
201
211
& ' Program: fpm(1)' , &
@@ -321,7 +331,7 @@ subroutine get_command_line_settings(cmd_settings)
321
331
select case (size (unnamed))
322
332
case (1 )
323
333
if (lget(' backfill' ))then
324
- name= ' .'
334
+ name= ' .'
325
335
else
326
336
write (stderr,' (*(7x,g0,/))' ) &
327
337
& ' <USAGE> fpm new NAME [[--lib|--src] [--app] [--test] [--example]]|[--full|--bare] [--backfill]'
@@ -424,6 +434,8 @@ subroutine get_command_line_settings(cmd_settings)
424
434
help_text= [character (len= widest) :: help_text, help_help]
425
435
case (' version' )
426
436
help_text= [character (len= widest) :: help_text, version_text]
437
+ case (' clean' )
438
+ help_text= [character (len= widest) :: help_text, help_clean]
427
439
case default
428
440
help_text= [character (len= widest) :: help_text, &
429
441
& ' <ERROR> unknown help topic "' // trim (unnamed(i))// ' "' ]
@@ -528,6 +540,11 @@ subroutine get_command_line_settings(cmd_settings)
528
540
fetch_only= lget(' fetch-only' ), verbose= lget(' verbose' ), &
529
541
clean= lget(' clean' ))
530
542
543
+ case (' clean' )
544
+ call set_args(common_args, help_clean)
545
+ allocate (fpm_clean_settings :: cmd_settings)
546
+ cmd_settings= fpm_clean_settings(unix= unix)
547
+
531
548
case default
532
549
533
550
if (which(' fpm-' // cmdarg).ne. ' ' )then
@@ -607,6 +624,7 @@ subroutine set_help()
607
624
' test Run the test programs ' , &
608
625
' update Update and manage project dependencies ' , &
609
626
' install Install project ' , &
627
+ ' clean Delete the "build" directory ' , &
610
628
' ' , &
611
629
' Enter "fpm --list" for a brief list of subcommand options. Enter ' , &
612
630
' "fpm --help" or "fpm SUBCOMMAND --help" for detailed descriptions. ' , &
@@ -728,6 +746,7 @@ subroutine set_help()
728
746
' + help Alternate to the --help switch for displaying help text. ' , &
729
747
' + list Display brief descriptions of all subcommands. ' , &
730
748
' + install Install project ' , &
749
+ ' + clean Delete the "build" directory ' , &
731
750
' ' , &
732
751
' Their syntax is ' , &
733
752
' ' , &
@@ -743,7 +762,8 @@ subroutine set_help()
743
762
' help [NAME(s)] ' , &
744
763
' list [--list] ' , &
745
764
' install [--profile PROF] [--flag FFLAGS] [--no-rebuild] [--prefix PATH] ' , &
746
- ' [options] ' , &
765
+ ' [options] ' , &
766
+ ' clean ' , &
747
767
' ' , &
748
768
' SUBCOMMAND OPTIONS ' , &
749
769
' -C, --directory PATH' , &
@@ -809,6 +829,7 @@ subroutine set_help()
809
829
' fpm new --help ' , &
810
830
' fpm run myprogram --profile release -- -x 10 -y 20 --title "my title" ' , &
811
831
' fpm install --prefix ~/.local ' , &
832
+ ' fpm clean ' , &
812
833
' ' , &
813
834
' SEE ALSO ' , &
814
835
' ' , &
@@ -1219,7 +1240,20 @@ subroutine set_help()
1219
1240
' ' , &
1220
1241
' fpm install --prefix $PWD --bindir exe' , &
1221
1242
' ' ]
1222
- end subroutine set_help
1243
+ help_clean= [character (len= 80 ) :: &
1244
+ ' NAME' , &
1245
+ ' clean(1) - delete the "build" directory' , &
1246
+ ' ' , &
1247
+ ' SYNOPSIS' , &
1248
+ ' fpm clean' , &
1249
+ ' ' , &
1250
+ ' DESCRIPTION' , &
1251
+ ' Prompts the user to confirm deletion of the "build" directory. If affirmative,' , &
1252
+ ' the "build" directory in the project root is deleted using os system specific' , &
1253
+ ' commands, forcing the recursive removal of all files and directories,' , &
1254
+ ' including dependencies.' , &
1255
+ ' ' ]
1256
+ end subroutine set_help
1223
1257
1224
1258
subroutine get_char_arg (var , arg )
1225
1259
character (len= :), allocatable , intent (out ) :: var
0 commit comments