lucky routes command does not work without any first argument
It causes periodically when works with cli commands:
roquie:test-lucky$ lucky gen.model VatNumberType
Created CreateVatNumberTypes::V20200919094107 in ./db/migrations/20200919094107_create_vat_number_types.cr
Generated VatNumberType in ./src/models/vat_number_type.cr
Generated VatNumberTypeOperation in ./src/operations/save_vat_number_type.cr
Generated VatNumberTypeQuery in ./src/queries/vat_number_type_query.cr
roquie:test-lucky$ lucky routes
Showing last frame. Use --error-trace for full trace.
Unhandled exception: Negative argument (ArgumentError)
from raise<ArgumentError>:NoReturn
from String#*<Int32>:String
from Crystal::TypeException+@Crystal::ErrorFormat#append_error_indicator<String::Builder, Int32, Int32, Int32>:(String::Builder | Nil)
from Crystal::TypeException+@Crystal::ErrorFormat#error_body<Nil, (String | Nil)>:(String | Nil)
from Crystal::TypeException+@Crystal::TypeException#append_to_s<IO::FileDescriptor, Nil>:(IO::FileDescriptor | Nil)
from Crystal::Command#run:(Bool | Nil)
from __crystal_main
from main
roquie:test-lucky$ lucky get.action.api
Showing last frame. Use --error-trace for full trace.
Unhandled exception: Negative argument (ArgumentError)
from raise<ArgumentError>:NoReturn
from String#*<Int32>:String
from Crystal::TypeException+@Crystal::ErrorFormat#append_error_indicator<String::Builder, Int32, Int32, Int32>:(String::Builder | Nil)
from Crystal::TypeException+@Crystal::ErrorFormat#error_body<Nil, (String | Nil)>:(String | Nil)
from Crystal::TypeException+@Crystal::TypeException#append_to_s<IO::FileDescriptor, Nil>:(IO::FileDescriptor | Nil)
from Crystal::Command#run:(Bool | Nil)
from __crystal_main
from main
roquie:test-lucky$ lucky routes --help
Showing last frame. Use --error-trace for full trace.
Unhandled exception: Negative argument (ArgumentError)
from raise<ArgumentError>:NoReturn
from String#*<Int32>:String
from Crystal::TypeException+@Crystal::ErrorFormat#append_error_indicator<String::Builder, Int32, Int32, Int32>:(String::Builder | Nil)
from Crystal::TypeException+@Crystal::ErrorFormat#error_body<Nil, (String | Nil)>:(String | Nil)
from Crystal::TypeException+@Crystal::TypeException#append_to_s<IO::FileDescriptor, Nil>:(IO::FileDescriptor | Nil)
from Crystal::Command#run:(Bool | Nil)
from __crystal_main
from main
roquie:test-lucky$ lucky get.action.api -h
Showing last frame. Use --error-trace for full trace.
Unhandled exception: Negative argument (ArgumentError)
from raise<ArgumentError>:NoReturn
from String#*<Int32>:String
from Crystal::TypeException+@Crystal::ErrorFormat#append_error_indicator<String::Builder, Int32, Int32, Int32>:(String::Builder | Nil)
from Crystal::TypeException+@Crystal::ErrorFormat#error_body<Nil, (String | Nil)>:(String | Nil)
from Crystal::TypeException+@Crystal::TypeException#append_to_s<IO::FileDescriptor, Nil>:(IO::FileDescriptor | Nil)
from Crystal::Command#run:(Bool | Nil)
from __crystal_main
from main
roquie:test-lucky$ lucky db.migrate
Showing last frame. Use --error-trace for full trace.
Unhandled exception: Negative argument (ArgumentError)
from raise<ArgumentError>:NoReturn
from String#*<Int32>:String
from Crystal::TypeException+@Crystal::ErrorFormat#append_error_indicator<String::Builder, Int32, Int32, Int32>:(String::Builder | Nil)
from Crystal::TypeException+@Crystal::ErrorFormat#error_body<Nil, (String | Nil)>:(String | Nil)
from Crystal::TypeException+@Crystal::TypeException#append_to_s<IO::FileDescriptor, Nil>:(IO::FileDescriptor | Nil)
from Crystal::Command#run:(Bool | Nil)
from __crystal_main
from main
roquie:test-lucky$ lucky get.action.api -h
Showing last frame. Use --error-trace for full trace.
Unhandled exception: Negative argument (ArgumentError)
from raise<ArgumentError>:NoReturn
from String#*<Int32>:String
from Crystal::TypeException+@Crystal::ErrorFormat#append_error_indicator<String::Builder, Int32, Int32, Int32>:(String::Builder | Nil)
from Crystal::TypeException+@Crystal::ErrorFormat#error_body<Nil, (String | Nil)>:(String | Nil)
from Crystal::TypeException+@Crystal::TypeException#append_to_s<IO::FileDescriptor, Nil>:(IO::FileDescriptor | Nil)
from Crystal::Command#run:(Bool | Nil)
from __crystal_main
from main
roquie:test-lucky$ lucky get.action.api -h
Showing last frame. Use --error-trace for full trace.
Unhandled exception: Negative argument (ArgumentError)
from raise<ArgumentError>:NoReturn
from String#*<Int32>:String
from Crystal::TypeException+@Crystal::ErrorFormat#append_error_indicator<String::Builder, Int32, Int32, Int32>:(String::Builder | Nil)
from Crystal::TypeException+@Crystal::ErrorFormat#error_body<Nil, (String | Nil)>:(String | Nil)
from Crystal::TypeException+@Crystal::TypeException#append_to_s<IO::FileDescriptor, Nil>:(IO::FileDescriptor | Nil)
from Crystal::Command#run:(Bool | Nil)
from __crystal_main
from main
roquie:test-lucky$ lucky gen.model -h
Generate a model, query, and save operation
Example:
lucky gen.model Project title:String description:String? completed:Bool priority:Int32
roquie:test-lucky$ lucky routes -h
Showing last frame. Use --error-trace for full trace.
Unhandled exception: Negative argument (ArgumentError)
from raise<ArgumentError>:NoReturn
from String#*<Int32>:String
from Crystal::TypeException+@Crystal::ErrorFormat#append_error_indicator<String::Builder, Int32, Int32, Int32>:(String::Builder | Nil)
from Crystal::TypeException+@Crystal::ErrorFormat#error_body<Nil, (String | Nil)>:(String | Nil)
from Crystal::TypeException+@Crystal::TypeException#append_to_s<IO::FileDescriptor, Nil>:(IO::FileDescriptor | Nil)
from Crystal::Command#run:(Bool | Nil)
from __crystal_main
from main
roquie:test-lucky$ lucky routes asd
Routing documentation:
https://luckyframework.org/guides/http-and-routing/routing-and-params
GET /api/me ▸ Api::Me::Show
POST /api/sign_ins ▸ Api::SignIns::Create
POST /api/sign_ups ▸ Api::SignUps::Create
GET / ▸ Home::Index
roquie:test-lucky$ lucky routes asd -h
Show all the routes for the app
Run this task with 'lucky routes'
roquie:test-lucky$ lucky routes asd
Routing documentation:
https://luckyframework.org/guides/http-and-routing/routing-and-params
GET /api/me ▸ Api::Me::Show
POST /api/sign_ins ▸ Api::SignIns::Create
POST /api/sign_ups ▸ Api::SignUps::Create
GET / ▸ Home::Index
roquie:test-lucky$ lucky routes --trac
Compiling... ⣽ ^C
roquie:test-lucky$ lucky routes --trace | pbcopy # <---------- In this place I think what I should was be create an issue at Github and trying to get a full trace log for you :))
Unhandled exception: Invalid option: --trace (OptionParser::InvalidOption)
from ../../../../../../../usr/local/Cellar/crystal/0.35.1_1/src/option_parser.cr:129:45 in '->'
from ../../../../../../../usr/local/Cellar/crystal/0.35.1_1/src/primitives.cr:255:3 in 'parse'
from lib/lucky/tasks/routes.cr:4:1 in 'print_help_or_call'
from lib/lucky_cli/src/lucky_cli/runner.cr:27:9 in 'run'
from tasks.cr:20:1 in '__crystal_main'
from ../../../../../../../usr/local/Cellar/crystal/0.35.1_1/src/crystal/main.cr:105:5 in 'main_user_code'
from ../../../../../../../usr/local/Cellar/crystal/0.35.1_1/src/crystal/main.cr:91:7 in 'main'
from ../../../../../../../usr/local/Cellar/crystal/0.35.1_1/src/crystal/main.cr:114:3 in 'main'
roquie:test-lucky$ lucky routes
Routing documentation:
https://luckyframework.org/guides/http-and-routing/routing-and-params
GET /api/me ▸ Api::Me::Show
POST /api/sign_ins ▸ Api::SignIns::Create
POST /api/sign_ups ▸ Api::SignUps::Create
GET / ▸ Home::Index
roquie:test-lucky$ lucky routes
Routing documentation:
https://luckyframework.org/guides/http-and-routing/routing-and-params
GET /api/me ▸ Api::Me::Show
POST /api/sign_ins ▸ Api::SignIns::Create
POST /api/sign_ups ▸ Api::SignUps::Create
GET / ▸ Home::Index
roquie:test-lucky$ lucky gen.model -h
Generate a model, query, and save operation
Example:
lucky gen.model Project title:String description:String? completed:Bool priority:Int32
roquie:test-lucky$
roquie:test-lucky$
roquie:test-lucky$ lucky db.migrate
Migrated CreateVatNumberTypes::V20200919094107
roquie:test-lucky$ lucky get.action.api -h
Task get.action.api not found. Did you mean 'gen.action.api'?
roquie:test-lucky$ lucky gen.action.api -h
Generate a new api action
Example:
lucky gen.action.api Api::Users::Index
roquie:test-lucky$ lucky gen.action.api Api::VatNumberTypes::Index
Done generating Api::VatNumberTypes::Index in ./src/actions/api/vat_number_types
roquie:test-lucky$ lucky routes
Showing last frame. Use --error-trace for full trace.
Unhandled exception: Negative argument (ArgumentError)
from raise<ArgumentError>:NoReturn
from String#*<Int32>:String
from Crystal::TypeException+@Crystal::ErrorFormat#append_error_indicator<String::Builder, Int32, Int32, Int32>:(String::Builder | Nil)
from Crystal::TypeException+@Crystal::ErrorFormat#error_body<Nil, (String | Nil)>:(String | Nil)
from Crystal::TypeException+@Crystal::TypeException#append_to_s<IO::FileDescriptor, Nil>:(IO::FileDescriptor | Nil)
from Crystal::Command#run:(Bool | Nil)
from __crystal_main
from main
roquie:test-lucky$ lucky routes --error-trace
Showing last frame. Use --error-trace for full trace.
Unhandled exception: Negative argument (ArgumentError)
from raise<ArgumentError>:NoReturn
from String#*<Int32>:String
from Crystal::TypeException+@Crystal::ErrorFormat#append_error_indicator<String::Builder, Int32, Int32, Int32>:(String::Builder | Nil)
from Crystal::TypeException+@Crystal::ErrorFormat#error_body<Nil, (String | Nil)>:(String | Nil)
from Crystal::TypeException+@Crystal::TypeException#append_to_s<IO::FileDescriptor, Nil>:(IO::FileDescriptor | Nil)
from Crystal::Command#run:(Bool | Nil)
from __crystal_main
from main
roquie:test-lucky$
# But flag `--error-trace` not showing more than default output.
I just use the tool like in docs and it behavior is so strange. I think is a little bug :)
CRYSTAL_CACHE_DIR=/Users/roquie/.cache/crystal
CRYSTAL_PATH=lib:/usr/local/Cellar/crystal/0.35.1_1/src
CRYSTAL_VERSION=0.35.1
CRYSTAL_LIBRARY_PATH=/usr/local/Cellar/crystal/0.35.1_1/embedded/lib:/usr/local/lib
CRYSTAL_OPTS=''
MacOS Catalina 10.15.6
Well that's an interesting bug 😅 What Lucky version are you using?
Latest, of course. Like 0.24.0 (installed from brew several days ago).
After reinstalling init.custom and coding without mistakes (like syntax or others) it works normal now...
I think it causes when I make mistakes in migrations. Mistakes like typos or use add instead of add_belongs_to in migrate method.
Ah. I wonder if it's a cache issue then. Maybe the compiled task was cached with the issue or something. We can leave it open for now and see if we can investigate further. If you run in to it again, or have a solid way to reproduce, let us know.