fsprojects / Argu

A declarative CLI argument parser for F#
https://fsprojects.github.io/Argu
MIT License
453 stars 75 forks source link

`-h` short option for `--help` #172

Closed omaus closed 2 years ago

omaus commented 2 years ago

Description

Users of a CLI app I work on complain about not being able to call the help by -h. Is there a way to implement it?

Known workarounds

// ugly as hell
[<EntryPoint>]
let main argv =

    let intermedRes =
        argv
        |> Array.map (
            fun str -> if str = "-h" then "--help" else str
        )

    let parser = ArgumentParser.Create<...>()

    parser.ParseCommandLine(inputs = intermedRes, ignoreMissing = true, ignoreUnrecognized = true)

    // ...
bartelink commented 2 years ago

https://github.com/fsprojects/Argu/blob/9a5c64f1253024813928bdcc44fc83de134e94f9/tests/Argu.Tests/Tests.fs#L835-L867 ? (In general I'd advise reading the source to find the answers to these kinds of questions - it's neat, short and educational!) (Am also intrigued as to what ecosystem uses -h as a convention for help - will now be questioning myself whenever I use it for host etc...)

omaus commented 2 years ago

Thank you, much appreciated. 👍🏻

(In general I'd advise reading the source to find the answers to these kinds of questions - it's neat, short and educational!)

You mean source code?
Educational, yes. I don't know if short would be the term I'd choose to describe reading through the source code, especially when it comes to Million Lines-Repos (which Argu is clearly not but they exist). 😅
You are right in terms of proper searching where I clearly failed (though I searched for "help" like, I assume, you did too).