Skip to content

Latest commit

 

History

History
79 lines (46 loc) · 3.11 KB

README.md

File metadata and controls

79 lines (46 loc) · 3.11 KB

Build Status codecov Ruby gem

Fylla

Fylla, the Norse word for complete, is an autocompletion script generator for the Thor framework.

It currently generates zsh completion scripts, but will soon have support for bash scripts as well.

Installation

Add this line to your application's Gemfile:

gem 'fylla'

And then execute:

$ bundle

Or install it yourself as:

$ gem install fylla

Usage

require 'thor'
require 'fylla' # needs to come before anything that forces Thor configuration
require 'cli' # has code like `class CLI < Thor` which forces Thor configuration

Fylla.load('cli') # must come before `#start()`

CLI.start(ARGV)

Fylla must be loaded before Thor.start is called in order for it to be used.

require 'fylla' must be called before any Thor code is accessed if you would like to use the completion: option. If you do not care about using the completion: flag in Options, then this requirement does not need to be met.

General use case will be to create a new subcommand or option that calls Fylla.zsh_completion(self)

Fylla#zsh_completion returns a string containing the entire zsh completion script, that you can use to do what you see fit.

Same for bash completion.

The only requirement for calling Fylla.zsh_completion(self) is that Thor has loaded all commands/options/etc.

For some examples, you can reference the test folder

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/snowe2010/fylla. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Fylla project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

Todo list

  • use desc if banner isn't present
  • add completion parameter to Option class to use by default
  • allow zsh_completion and bash_completion to be called from anywhere. This might be impossible.
  • allow supplying custom templates