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

The namespaces don't work as documented #792

Open
timuckun opened this issue Jul 17, 2022 · 4 comments
Open

The namespaces don't work as documented #792

timuckun opened this issue Jul 17, 2022 · 4 comments

Comments

@timuckun
Copy link

See the following gist https://gist.github.com/timuckun/4b1e8f860cd47e0dc27423cad9563f4d

Calling this file results in this output (notice the lack of namespaces)

 ./do
Commands:
  do dump            # dumps the database using pgdump
  do help [COMMAND]  # Describe available commands or one specific command
  do restore         # loads the database from pgdump

Commands:
  do help [COMMAND]  # Describe available commands or one specific command
  do start           # starts docker compose
@apurvis
Copy link

apurvis commented Aug 11, 2022

+1

@timuckun
Copy link
Author

Is anybody even looking at these tickets?

@p8
Copy link
Member

p8 commented Aug 9, 2023

Renaming the file to Thorfile and removing the calls to start does show the namespace when running thor list

require 'thor'
require 'dotenv'
Dotenv.load

module Db
  class Ops < Thor
    namespace :db
    def self.exit_on_failure?
      true
    end

    desc 'dump', 'dumps the database using pgdump'
    def backup
      puts 'Backup'
    end
    desc 'restore', 'loads the database from pgdump'
    def restore
      puts 'restore'
    end
  end
end

module Docker
  class Commands < Thor
    namespace :docker
    desc 'start', 'starts docker compose'
    def start; end
  end
end

Outputs:

db
--
thor db:dump     # dumps the database using pgdump
thor db:restore  # loads the database from pgdump

docker
------
thor docker:start  # starts docker compose

I'm not sure what the expected behaviour is for the original example file.
Is this something Thor should support?

@p8
Copy link
Member

p8 commented Aug 9, 2023

Hmm, this also how the https://github.com/rails/thor/blob/5fb6206a6d2d7bfb40bcb851c2e118ba39f69757/spec/fixtures/help.thor is implemented so I guess this is a bug.

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

3 participants