dillonkearns / elm-graphql

Autogenerate type-safe GraphQL queries in Elm.
https://package.elm-lang.org/packages/dillonkearns/elm-graphql/latest
BSD 3-Clause "New" or "Revised" License
778 stars 107 forks source link

Improve --help #463

Open lydell opened 3 years ago

lydell commented 3 years ago

This is what the help output looks like on Windows:

PS C:\Users\Simon\stuff\elm-tst> npx elm-graphql --help
C:\Users\Simon\stuff\elm-tst\node_modules\@dillonkearns\elm-graphql\bin\elm-graphql <url> [--base <base>] [--output <output>] [--exclude-deprecated] [--header <header>]... [--scalar-codecs <scalar-codecs>] [--skip-elm-format] # generate files based on the schema at `url`
C:\Users\Simon\stuff\elm-tst\node_modules\@dillonkearns\elm-graphql\bin\elm-graphql --introspection-file <introspection-file> [--base <base>] [--output <output>] [--scalar-codecs <scalar-codecs>] [--skip-elm-format]
C:\Users\Simon\stuff\elm-tst\node_modules\@dillonkearns\elm-graphql\bin\elm-graphql --schema-file <schema-file> [--base <base>] [--output <output>] [--scalar-codecs <scalar-codecs>] [--skip-elm-format]

I don’t even know where to start reading 😄

(It’s a little less verbose on macOS (no absolute paths), but still a bit hard to understand.)

dillonkearns commented 3 years ago

Thanks for the report @lydell!

I found the problem. My cli options parser library is splitting based on /, but Windows uses \.

https://github.com/dillonkearns/elm-cli-options-parser/blob/51b6ec77e6a17372c0bb95137790fa6041bb7086/src/Cli/Program.elm#L269

It's probably good enough to do a split on either back or forward slashes in that library. It's a bit of a heuristic since technically the binary name could include a slash, but I think it's good enough in practice.