Closed geirolz closed 1 month ago
I actually wanted to use numbers as the default from the start but sbt doesn't allow aliases to start with a number. I guess it's similar rules to scala identifiers (can have a number in it but can't start with one).
I tried it again just in case and get this from sbt (using plain addCommandAlias
):
Invalid alias name '1'.
[warn] Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? (default: r)
Ouch! I see
What if we add a letter as prefix of the numbers ? Like t
for Task
[info] Useful sbt tasks:
[info] t1. run - Start application
[info] t2. test - Run unit tests
[info] t3. it:test - Run integration unit tests
It's a tread off, I know
I don't see many other solutions give this limitation unfortunately. It would be interesting asking to SBT why they don't support number aliases
That seems reasonable. By the way, you can already do this currently but I noticed that I hadn't documented it in the README. The following should do what you want:
autoAliasGen := LazyList.from(1).map(n => s"t$n")
(note that sbt uses Scala 2.12 so the LazyList here is at scala.collection.compat.immutable.LazyList
)
Anyway I'll document that now. In future versions I could perhaps add some built-in commonly used generators. But maybe it's not worth it either considering it's a simple one-liner most of the time.
Thank you so much @reibitto!
It would be nice to have a key to specify the auto alias strategy, having the possibility to choose between letters and numbers.
Example with Letters
Produces:
Example with Numbers
Produces: