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

Thor::Group: disparities between cli help COMMAND and cli command --help #402

Open
davidcelis opened this issue Mar 2, 2014 · 3 comments

Comments

@davidcelis
Copy link

I'm building a CLI using Thor::Group to register commands and noticed that cli help command is not nearly as helpful as cli command --help. The longer description printed by using cli command --help shows the Thor::Group command's options, but cli help command does not. Also, cli command --help gives a weird (and wrong) command name. Lastly, the desc is only printed when running cli help command and not when running cli command --help (unless I duplicate the desc in the Thor::Group class itself)

My example code is at https://github.com/davidcelis/creperie where I'm building a CLI a la Rails has to create new Crepe applications. You can reproduce my example below:

$ git clone git@github.com:davidcelis/creperie.git
$ cd creperie
$ gem build creperie.gemspec
$ gem install creperie-0.0.1.pre.gem

$ crepe help new
Usage:
  crepe new [APP_NAME]

Create a new Crepe application.

$ crepe new --help
Usage:
  crepe creperie:generators:app APP_NAME

Options:
  -B, [--skip-bundle]  # Don't run bundle install
  -G, [--skip-git]     # Don't create a git repository
  -h, [--help]         # Print this usage information and exit

Runtime options:
  -f, [--force]    # Overwrite files that already exist
  -p, [--pretend]  # Run but do not make any changes
  -q, [--quiet]    # Suppress status output
  -s, [--skip]     # Skip files that already exist

Create a new Crepe application.

$ crepe creperie:generators:app
Could not find command "creperie:generators:app"

So, in summary:

  1. crepe help new prints very basic USAGE instructions despite being the help path given to users
  2. crepe new --help prints the desired USAGE instructions but is not discoverable
    • Related, if class_option :help isn't provided, --help (although clearly available as an option) is not listed under the Options banner despite it seemingly being available by default all the time.
  3. crepe new --help prints the wrong command name
  4. If desc is not duplicated inside of the Thor::Group class, the "Say hello!" description is only printed in cli help COMMAND and not cli COMMAND --help
@davidcelis
Copy link
Author

This may be a (more detailed) duplicate of #375 and might be fixed by #387

@davidcelis
Copy link
Author

This is still a problem on master, despite #387 and #391 being merged in.

@xuanyu-h
Copy link

Here is an ugly way

class CLI < Thor

  desc "xx", "xxx"
  def xx *args
    prepare :xx
    # do something
  end


  private

    def prepare task
      if options.help?
        help(task.to_s)
        raise SystemExit
      end
    end
end

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

2 participants