luckyframework / luckyframework/lucky_task
Task DSL for arg and positional_arg should warn about naming collisions
Nobody has claimed this yet.
- Dominant language
- Crystal
- Stars
- 8
- Forks
- 5
- PR merge metrics
- No merged PRs in 30d
Description
This will put you in a world of confusion:
```crystal
class MyTask < LuckyCli::Task
arg :summary, "", optional: true
positional_arg :name, ""
def call(io : IO = STDOUT)
# do stuff
end
end
```
Macro-generated args can easily conflict with the in-use internal namespace in the task infrastructure. When you run `lucky -h` with that task in your tasks directory, you'll get an opaque error because calling `.name` on the class isn't doing what lucky_cli thought it would do. You'll get:
`Unhandled exception: name is required, but no value was passed. (Exception)`
I wonder if it makes sense to:
- namespace the LuckyCli::Task infrastructure, for example instead of a `summary` method being generated from the `summary` macro, maybe it generates a `_task_summary` method.
- encapsulate the declared arguments within an Args object of some sort. Within a task, a `arg :summary` would be accessed via `args.summary` instead of just `summary`.
- simply warn the developer that they're about to shoot themselves in the foot by declaring an arg with a name of: name, summary, help_message, call, etc
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the macro-generated implementations of `arg` and `positional_arg`, then reproduce the collision by running `lucky -h` with the task shown in the issue. Done means the conflicting names are identified and a clear warning is emitted or an agreed encapsulation prevents the opaque error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- crystal
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100