Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ash.gen.resource trips up when hypenated option is mistyped with underscore instead #108

Closed
albinkc opened this issue Oct 22, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@albinkc
Copy link

albinkc commented Oct 22, 2024

Mistyping with an underscore instead of hyphen results in a different error than expected

Note the underscore between uuid and v7

mix ash.gen.resource Scratch.Tweet --uuid_v7-primary-key id -a body:string -r belongs_to:owner:Scratch.User
** (Mix) Could not invoke task "ash.gen.resource": 1 error found!
--uuid_v7-primary-key : Missing argument of type string

Expected behavior
I'm getting the correct error when I use another valid symbol ~ here

mix ash.gen.resource Scratch.Tweet --uuid~v7_primary_key id -a body:string -r belongs_to:owner:Scratch.User
** (Mix) Could not invoke task "ash.gen.resource": 1 error found!
--uuid~v7_primary_key : Unknown option. Did you mean --uuid-primary-key?

Runtime
Erlang/OTP 27 [erts-15.1] [source] [64-bit] [smp:10:10] [ds:10:10:10] [async-threads:1] [jit]

Elixir 1.17.3 (compiled with Erlang/OTP 27)
Mac 15.0.1
Ash 3.4.35
Igniter 0.3.72

Additional context
The project was created with igniter_new-0.4.5 with
mix igniter.new scratch --install ash

@albinkc albinkc added the bug Something isn't working label Oct 22, 2024
@albinkc
Copy link
Author

albinkc commented Oct 22, 2024

Maybe out-of-scope but I made an interesting observation:

The error with the did you mean... makes different choices for autocorrects

--uuid~v7_primary_key autocorrects to --uuid-primary-key but
--uuid-v7-primary~key correctly autocorrects to --uuid-v7-primary-key

@zachdaniel zachdaniel transferred this issue from ash-project/ash Oct 22, 2024
@zachdaniel
Copy link
Contributor

Looks to me like a bug in elixir, specifically in OptionParser. I've opened a fix here: elixir-lang/elixir#13925

I'll close this issue with that in mind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants