Argu


Argu

Argu (pronounced "Argue") is a declarative CLI argument/XML configuration parser for F# applications. Allows quick definition of argument parsing schema through F# union declarations.

Argu can be installed from NuGet:
PM> Install-Package Argu

Argu is a mature library that comes with many features

  • Declarative: easily model your syntax definitions using F# unions.
  • Convenient: automatic derivation of CLI syntax and documentation.
  • Customizable: control most aspects of your parser behaviour.
  • Subcommands: use contextual syntax with nested argument schemata.

Introduction

The library is based on the simple observation that configuration parameters can be naturally described using discriminated unions. For instance:

1: 
2: 
3: 
4: 
5: 
type Arguments =
    | Working_Directory of path:string
    | Listener of host:string * port:int
    | Log_Level of level:int
    | Detach

Argu takes such discriminated unions and generates a corresponding argument parsing scheme. For example, a parser generated from the above template would take the following command line input

1: 
--working-directory /var/run --listener localhost 8080 --detach

and parse it into the list

1: 
[ Working_Directory "/var/run" ; Listener("localhost", 8080) ; Detach ]

Argu is also capable of reading the AppSettings section of an application's configuration file:

1: 
2: 
3: 
4: 
5: 
6: 
<appSettings>
    <add key="working directory" value="C:\temp" />
    <add key="listener" value="192.168.0.3, 2675" />
    <add key="log level" value="3" />
    <add key="detach" value="true" />
</appSettings>

Who uses Argu?

Documentation

  • Tutorial A short walkthrough of Argu features.

  • API Reference contains automatically generated documentation for all types, modules and functions in the library.

Contributing and copyright

The project is hosted on GitHub where you can report issues, fork the project and submit pull requests.

The library is available under the MIT License. For more information see the License file in the GitHub repository.

namespace System
type Arguments =
  | Working_Directory of path: string
  | Listener of host: string * port: int
  | Log_Level of level: int
  | Detach

Full name: Index.Arguments
union case Arguments.Working_Directory: path: string -> Arguments
Multiple items
val string : value:'T -> string

Full name: Microsoft.FSharp.Core.Operators.string

--------------------
type string = String

Full name: Microsoft.FSharp.Core.string
union case Arguments.Listener: host: string * port: int -> Arguments
Multiple items
val int : value:'T -> int (requires member op_Explicit)

Full name: Microsoft.FSharp.Core.Operators.int

--------------------
type int = int32

Full name: Microsoft.FSharp.Core.int

--------------------
type int<'Measure> = int

Full name: Microsoft.FSharp.Core.int<_>
union case Arguments.Log_Level: level: int -> Arguments
union case Arguments.Detach: Arguments
Fork me on GitHub