Skip to content

Commit

Permalink
add --bin to remove also bin directories
Browse files Browse the repository at this point in the history
  • Loading branch information
enricosada authored and Krzysztof-Cieslak committed Aug 23, 2018
1 parent bd34301 commit 91b7e4d
Showing 1 changed file with 20 additions and 21 deletions.
41 changes: 20 additions & 21 deletions Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,22 @@ with
match s with
| Bin _ -> "remove also bin directories."

let removeobjs () =

try
let dir = Directory.GetCurrentDirectory()

Directory.GetFiles(dir, "*.*proj", SearchOption.AllDirectories)
|> Seq.map (fun p ->
let p = Path.GetDirectoryName p
Path.Combine (p, "obj")
)
|> Seq.iter (fun n ->
if Directory.Exists n then
Directory.Delete(n, true)
printfn "Deleted: %s" n)
0
with
| ex ->
printfn "%s" ex.Message
-1
let removeobjs andBin =

let dir = Directory.GetCurrentDirectory()

Directory.GetFiles(dir, "*.*proj", SearchOption.AllDirectories)
|> Seq.map Path.GetDirectoryName
|> Seq.distinct
|> Seq.collect (fun p -> seq {
yield Path.Combine (p, "obj")
if andBin then
yield Path.Combine (p, "bin")
})
|> Seq.filter Directory.Exists
|> Seq.iter (fun n ->
Directory.Delete(n, true)
printfn "Deleted: %s" n)

[<EntryPoint>]
let main argv =
Expand All @@ -38,7 +35,9 @@ let main argv =

let andBin = results.Contains Bin

removeobjs ()
removeobjs andBin

0
with
| :? ArguParseException as ex ->
printfn "%s" ex.Message
Expand All @@ -47,4 +46,4 @@ let main argv =
| _ -> -2
| ex ->
printfn "%s" ex.Message
-3
-1

0 comments on commit 91b7e4d

Please sign in to comment.