Skip to content

Commit

Permalink
add Argu for cli args
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 4adf83a commit bd34301
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
33 changes: 31 additions & 2 deletions Program.fs
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
open System.IO
open Argu

type CLIArguments =
| Bin
with
interface IArgParserTemplate with
member s.Usage =
match s with
| Bin _ -> "remove also bin directories."

let removeobjs () =

[<EntryPoint>]
let main _ =
try
let dir = Directory.GetCurrentDirectory()

Expand All @@ -19,3 +28,23 @@ let main _ =
| ex ->
printfn "%s" ex.Message
-1

[<EntryPoint>]
let main argv =
try
let parser = ArgumentParser.Create<CLIArguments>(programName = "removeobj")

let results = parser.Parse argv

let andBin = results.Contains Bin

removeobjs ()
with
| :? ArguParseException as ex ->
printfn "%s" ex.Message
match ex.ErrorCode with
| ErrorCode.HelpText -> 0
| _ -> -2
| ex ->
printfn "%s" ex.Message
-3
4 changes: 4 additions & 0 deletions removeobj.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@
<Compile Include="Program.fs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Argu" Version="5.1.0" />
</ItemGroup>

</Project>

0 comments on commit bd34301

Please sign in to comment.