Add task completions
This commit is contained in:
parent
7a19598927
commit
2c5bfabb5e
181
src/_rails
181
src/_rails
|
@ -28,13 +28,14 @@
|
|||
# Description
|
||||
# -----------
|
||||
#
|
||||
# Completion script for Ruby on Rails (https://rubyonrails.org/).
|
||||
# Completion script for Ruby on Rails 7.1.0 (https://rubyonrails.org/).
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
# Authors
|
||||
# -------
|
||||
#
|
||||
# * Kazuya Takeshima (https://github.com/mitukiii)
|
||||
# * Shohei Yoshida (https://github.com/syohex)
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
|
@ -127,6 +128,31 @@ _rails() {
|
|||
'(-p --pride)'{-p,--pride}'[Show your testing pride]' \
|
||||
&& ret=0
|
||||
;;
|
||||
(runner|r)
|
||||
_arguments \
|
||||
'(-e --environment)'{-e,--environment=}'[The environment to run "runner"]:env:(test development production)' \
|
||||
'*:: :_files -g "*.rb"' \
|
||||
&& ret=0
|
||||
;;
|
||||
(plugin)
|
||||
_arguments \
|
||||
'1: :(new)' \
|
||||
'*:: :_rails_new' \
|
||||
&& ret=0
|
||||
;;
|
||||
(routes)
|
||||
_arguments \
|
||||
'(-c --controller)'{-c,--controller=}'[Filter by a specific controller]:controller' \
|
||||
'(-g --grep)'{-g,--grep}'[Grep routes by a specific pattern]' \
|
||||
'(-E --expanded)'{-E,--expanded}'[Print routes expanded vertically with parts explained]' \
|
||||
'(-u --unused)'{-u,--unused}'[Print unused routes]' \
|
||||
&& ret=0
|
||||
;;
|
||||
(*)
|
||||
_arguments \
|
||||
'(- *)'{-h,--help}'[Show help message and quit]' \
|
||||
&& ret=0
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
@ -153,9 +179,93 @@ _rails_subcommands() {
|
|||
{test,t}'[Run tests]'
|
||||
"test\\:system[Run systems test only]"
|
||||
{dbconsole,db}'[Start a console for the database specified in config/database.yml]'
|
||||
{destroy,d}'[Remove code generated by "bin/rails generates"]'
|
||||
plugin'[Install a plugin]'
|
||||
{runner,r}'[Run a piece of code in the application environment]'
|
||||
|
||||
# generated by ./bin/rails --help | ruby -ne '(b=$2;printf("%s[%s]\n", $1.gsub(/:/,"\\:"),b.strip)) if /^([a-z0-9_:]+)\S*\s+([^(\n]+)/'
|
||||
"about[List versions of all Rails frameworks and the environment]"
|
||||
"action_mailbox\:ingress\:exim[Relay an inbound email from Exim to Action Mailbox]"
|
||||
"action_mailbox\:ingress\:postfix[Relay an inbound email from Postfix to Action Mailbox]"
|
||||
"action_mailbox\:ingress\:qmail[Relay an inbound email from Qmail to Action Mailbox]"
|
||||
"action_mailbox\:install[Install Action Mailbox and its dependencies]"
|
||||
"action_mailbox\:install\:migrations[Copy migrations from action_mailbox to application]"
|
||||
"action_text\:install[Copy over the migration, stylesheet, and JavaScript files]"
|
||||
"action_text\:install\:migrations[Copy migrations from action_text to application]"
|
||||
"active_storage\:install[Copy over the migration needed to the application]"
|
||||
"app\:template[Apply the template supplied by LOCATION=]"
|
||||
"app\:update[Update configs and some other initially generated files]"
|
||||
"assets\:clean[Remove old compiled assets]"
|
||||
"assets\:clobber[Remove compiled assets]"
|
||||
"assets\:environment[Load asset compile environment]"
|
||||
"assets\:precompile[Compile all the assets named in config.assets.precompile]"
|
||||
"cache_digests\:dependencies[Lookup first-level dependencies for TEMPLATE]"
|
||||
"cache_digests\:nested_dependencies[Lookup nested dependencies for TEMPLATE]"
|
||||
"credentials\:diff[Enroll/disenroll in decrypted diffs of credentials using git]"
|
||||
"credentials\:edit[Open the decrypted credentials in $VISUAL or $EDITOR for editing]"
|
||||
"credentials\:show[Show the decrypted credentials]"
|
||||
"db\:create[Create the database from DATABASE_URL or config/database.yml for the current RAILS_ENV]"
|
||||
"db\:drop[Drop the database from DATABASE_URL or config/database.yml for the current RAILS_ENV]"
|
||||
"db\:encryption\:init[Generate a set of keys for configuring Active Record encryption in a given environment]"
|
||||
"db\:environment\:set[Set the environment value for the database]"
|
||||
"db\:fixtures\:load[Load fixtures into the current environment's database]"
|
||||
"db\:migrate[Migrate the database]"
|
||||
"db\:migrate\:down[Run the 'down' for a given migration VERSION]"
|
||||
"db\:migrate\:redo[Roll back the database one migration and re-migrate up]"
|
||||
"db\:migrate\:status[Display status of migrations]"
|
||||
"db\:migrate\:up[Run the 'up' for a given migration VERSION]"
|
||||
"db\:prepare[Run setup if database does not exist, or run migrations if it does]"
|
||||
"db\:reset[Drop and recreate all databases from their schema for the current environment and load the seeds]"
|
||||
"db\:rollback[Roll the schema back to the previous version]"
|
||||
"db\:schema\:cache\:clear[Clear a db/schema_cache.yml file]"
|
||||
"db\:schema\:cache\:dump[Create a db/schema_cache.yml file]"
|
||||
"db\:schema\:dump[Create a database schema file]"
|
||||
"db\:schema\:load[Load a database schema file]"
|
||||
"db\:seed[Load the seed data from db/seeds.rb]"
|
||||
"db\:seed\:replant[Truncate tables of each database for current environment and load the seeds]"
|
||||
"db\:setup[Create all databases, load all schemas, and initialize with the seed data]"
|
||||
"db\:system\:change[Change 'config/database.yml' and your database gem to the target database]"
|
||||
"db\:version[Retrieve the current schema version number]"
|
||||
"destroy[Remove code generated by 'bin/rails generate']"
|
||||
"dev\:cache[Toggle development mode caching on/off]"
|
||||
"encrypted\:edit[Open the decrypted file in $VISUAL or $EDITOR for editing]"
|
||||
"encrypted\:show[Show the decrypted contents of the file]"
|
||||
"importmap\:install[Setup Importmap for the app]"
|
||||
"initializers[Print out all defined initializers in the order they are invoked by Rails.]"
|
||||
"log\:clear[Truncate all/specified *.log files in log/ to zero bytes]"
|
||||
"middleware[Print out your Rack middleware stack]"
|
||||
"notes[Show comments in your code annotated with FIXME, OPTIMIZE, and TODO]"
|
||||
"restart[Restart app by touching tmp/restart.txt]"
|
||||
"routes[List all the defined routes]"
|
||||
"runner[Run Ruby code in the context of your application]"
|
||||
"secret[Generate a cryptographically secure secret key]"
|
||||
"secrets\:edit[**deprecated** Open the secrets in $VISUAL or $EDITOR for editing]"
|
||||
"secrets\:show[**deprecated** Show the decrypted secrets]"
|
||||
"stats[Report code statistics]"
|
||||
"stimulus\:install[Install Stimulus into the app]"
|
||||
"stimulus\:install\:importmap[Install Stimulus on an app running importmap-rails]"
|
||||
"stimulus\:install\:node[Install Stimulus on an app running node]"
|
||||
"test\:all[Run all tests, including system tests]"
|
||||
"test\:channels[Run tests in test/channels]"
|
||||
"test\:controllers[Run tests in test/controllers]"
|
||||
"test\:db[Reset the database and run 'bin/rails test']"
|
||||
"test\:functionals[Run tests in test/controllers, test/mailers, and test/functional]"
|
||||
"test\:generators[Run tests in test/lib/generators]"
|
||||
"test\:helpers[Run tests in test/helpers]"
|
||||
"test\:integration[Run tests in test/integration]"
|
||||
"test\:jobs[Run tests in test/jobs]"
|
||||
"test\:mailboxes[Run tests in test/mailboxes]"
|
||||
"test\:mailers[Run tests in test/mailers]"
|
||||
"test\:models[Run tests in test/models]"
|
||||
"test\:units[Run tests in test/models, test/helpers, and test/unit]"
|
||||
"time\:zones[List all time zones, list by two-letter country code]"
|
||||
"tmp\:clear[Clear cache, socket and screenshot files from tmp/]"
|
||||
"tmp\:create[Create tmp directories for cache, sockets, and pids]"
|
||||
"turbo\:install[Install Turbo into the app]"
|
||||
"turbo\:install\:importmap[Install Turbo into the app with asset pipeline]"
|
||||
"turbo\:install\:node[Install Turbo into the app with webpacker]"
|
||||
"turbo\:install\:redis[Switch on Redis and use it in development]"
|
||||
"version[Show the Rails version]"
|
||||
"yarn\:install[Install all JavaScript dependencies as specified via Yarn]"
|
||||
"zeitwerk\:check[Check project structure for Zeitwerk compatibility]"
|
||||
)
|
||||
fi
|
||||
|
||||
|
@ -181,7 +291,7 @@ _rails_new() {
|
|||
'(-G --skip-git)'{-G,--skip-git}'[Skip git init]' \
|
||||
--skip-docker'[Skip Dockerfile]' \
|
||||
--skip-keeps'[Skip source control .keep files]' \
|
||||
'(-M --skip-action-mailer)'{-M,--skip-action-mailer}'[Skip Action Mailder files]' \
|
||||
'(-M --skip-action-mailer)'{-M,--skip-action-mailer}'[Skip Action Mailer files]' \
|
||||
--skip-action-mailbox'[Skip Action Mailbox gem]' \
|
||||
--skip-action-text'[Skip Action Text gem]' \
|
||||
'(-O --skip-active-record)'{-O,--skip-active-record}'[Skip Active Record files]' \
|
||||
|
@ -379,69 +489,6 @@ _rails_generate_generator() {
|
|||
_values 'generators' $generators
|
||||
}
|
||||
|
||||
_rails_plugin() {
|
||||
local context state line curcontext="$curcontext"
|
||||
|
||||
if (( CURRENT > 2 )); then
|
||||
(( CURRENT-- ))
|
||||
shift words
|
||||
_call_function - "_rails_plugin_${words[1]}" || _nothing
|
||||
else
|
||||
__rails_plugin_commands
|
||||
fi
|
||||
}
|
||||
|
||||
__rails_plugin_commands() {
|
||||
_values 'plugin command' \
|
||||
install'[Install plugin(s) from known repositories or URLs]' \
|
||||
remove'[Uninstall plugins]' \
|
||||
new
|
||||
}
|
||||
|
||||
_rails_plugin_install() {
|
||||
_arguments \
|
||||
'(-x --externals)'{-x,--externals}'[Use svn:externals to grab the plugin. Enables plugin updates and plugin versioning]' \
|
||||
'(-o --checkout)'{-o,--checkout}'[Use svn checkout to grab the plugin. Enables updating but does not add a svn:externals entry]' \
|
||||
'(-e --export)'{-e,--export}'[Use svn export to grab the plugin. Exports the plugin, allowing you to check it into your local repository. Does not enable updates or add an svn:externals entry]' \
|
||||
'(-q --quiet)'{-q,--quiet}'[Suppresses the output from installation. Ignored if -v is passed (rails plugin -v install ...)]' \
|
||||
'(-r --revision)'{-r,--revision=}'[Checks out the given revision from subversion or git. Ignored if subversion/git is not used]:revision' \
|
||||
'(-f --force)'{-f,--force}"[Reinstalls a plugin if it's already installed]" \
|
||||
'*:plugin:_urls'
|
||||
}
|
||||
|
||||
_rails_plugin_remove() {
|
||||
local -a plugins
|
||||
|
||||
plugins=($(_call_program rails_plugins ls -1 vendor/plugins))
|
||||
|
||||
_describe -t plugins 'plugin' plugins
|
||||
}
|
||||
|
||||
_rails_plugin_new() {
|
||||
_rails_new
|
||||
}
|
||||
|
||||
_rails_runner() {
|
||||
local context state line curcontext="$curcontext"
|
||||
|
||||
_arguments -C \
|
||||
'(- *)'{-h,--help}'[Show this help message]' \
|
||||
'(-e --environment)'{-e,--environment=}'[Specifies the environment for the runner to operate under (test/development/production)]:name:(test development production)' \
|
||||
': :->code_or_path'
|
||||
|
||||
case "$state" in
|
||||
code_or_path)
|
||||
_alternative \
|
||||
'files:filename:_files -g "*.rb"' \
|
||||
'codes:ruby code:_guard "^-*" "ruby code"'
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
_rails_r() {
|
||||
_rails_runner
|
||||
}
|
||||
|
||||
# Utilities
|
||||
(( $+functions[_rails_is_in_app] )) ||
|
||||
_rails_is_in_app() {
|
||||
|
|
Loading…
Reference in New Issue