Skip to content

Better error handling and documentation around query_packwerk console #3

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

Open
4 tasks
technicalpickles opened this issue Apr 7, 2025 · 0 comments
Open
4 tasks

Comments

@technicalpickles
Copy link
Contributor

I noticed this while trying a few variations of the command to get help usage:

❯ query_packwerk console --help
Loading packwerk context in --help...
/Users/josh.nichols/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/query_packwerk-0.1.0/lib/query_packwerk/console.rb:16:in 'Dir.chdir': No such file or directory @ dir_chdir0 - --help (Errno::ENOENT)
        from /Users/josh.nichols/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/query_packwerk-0.1.0/lib/query_packwerk/console.rb:16:in 'QueryPackwerk::Console.start'
        from /Users/josh.nichols/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/sorbet-runtime-0.5.11987/lib/types/private/methods/call_validation.rb:282:in 'UnboundMethod#bind_call'
        from /Users/josh.nichols/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/sorbet-runtime-0.5.11987/lib/types/private/methods/call_validation.rb:282:in 'T::Private::Methods::CallValidation.validate_call'
        from /Users/josh.nichols/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/sorbet-runtime-0.5.11987/lib/types/private/methods/_methods.rb:277:in 'block in QueryPackwerk::Console._on_method_added'
        from /Users/josh.nichols/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/query_packwerk-0.1.0/lib/query_packwerk/cli.rb:16:in 'QueryPackwerk::CLI#console'
        from /Users/josh.nichols/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/sorbet-runtime-0.5.11987/lib/types/private/methods/call_validation.rb:282:in 'UnboundMethod#bind_call'
        from /Users/josh.nichols/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/sorbet-runtime-0.5.11987/lib/types/private/methods/call_validation.rb:282:in 'T::Private::Methods::CallValidation.validate_call'
        from /Users/josh.nichols/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/sorbet-runtime-0.5.11987/lib/types/private/methods/_methods.rb:277:in 'block in QueryPackwerk::CLI#_on_method_added'
        from /Users/josh.nichols/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/thor-1.3.2/lib/thor/command.rb:28:in 'Thor::Command#run'
        from /Users/josh.nichols/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/thor-1.3.2/lib/thor/invocation.rb:127:in 'Thor::Invocation#invoke_command'
        from /Users/josh.nichols/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/thor-1.3.2/lib/thor.rb:538:in 'Thor.dispatch'
        from /Users/josh.nichols/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/thor-1.3.2/lib/thor/base.rb:584:in 'Thor::Base::ClassMethods#start'
        from /Users/josh.nichols/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/query_packwerk-0.1.0/exe/query_packwerk:7:in '<top (required)>'
        from /Users/josh.nichols/.local/share/mise/installs/ruby/3.4.2/bin/query_packwerk:25:in 'Kernel#load'
        from /Users/josh.nichols/.local/share/mise/installs/ruby/3.4.2/bin/query_packwerk:25:in '<main>'

sig { params(directory: String).void }
def console(directory = Dir.pwd)

❯ query_packwerk help console
Usage:
  query_packwerk console

Query packwerk in the current directory via console

I think this could benefit from a few improvements:

  • make sure --help is supported everywhere with a class_option
  • update desc call to include DIRECTORY, ie desc 'console DIRECTORY'
  • make sure the description matches the behavior (ie don't say 'current directory' if it can be passed in)
  • error check that directory exists, and give an appropriate error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant