2010-10-17 14 views
71

¿Por qué algunas tareas de rake no figuran en rake -T? Me gusta db:migrate:reset? Puedo ejecutarlo sin ningún problema, pero ¿por qué no aparece en la lista? ¿Hay alguna manera de obtener una lista completa de tareas de rake?¿Por qué rake db: migrate: reset no listado en rake -T?

 
% rake -T 
(in /home/zeus/projects/my_project) 
rake about    # List versions of all Rails frameworks and the environment 
rake db:create   # Create the database from config/database.yml for the current Rails.env (use db:create:all to create all dbs in the config) 
rake db:drop   # Drops the database for the current Rails.env (use db:drop:all to drop all databases) 
rake db:fixtures:load # Load fixtures into the current environment's database. 
rake db:migrate   # Migrate the database (options: VERSION=x, VERBOSE=false). 
rake db:migrate:status # Display status of migrations 
rake db:rollback  # Rolls the schema back to the previous version (specify steps w/ STEP=n). 
rake db:schema:dump  # Create a db/schema.rb file that can be portably used against any DB supported by AR 
rake db:schema:load  # Load a schema.rb file into the database 
rake db:seed   # Load the seed data from db/seeds.rb 
rake db:setup   # Create the database, load the schema, and initialize with the seed data (use db:reset to also drop the db first) 
rake db:structure:dump # Dump the database structure to an SQL file 
rake db:version   # Retrieves the current schema version number 
rake doc:app   # Generate docs for the app -- also availble doc:rails, doc:guides, doc:plugins (options: TEMPLATE=/rdoc-template.rb, TITLE="Custom Title") 
rake erd    # Generate an Entity-Relationship Diagram based on your models 
rake log:clear   # Truncates all *.log files in log/ to zero bytes 
rake middleware   # Prints out your Rack middleware stack 
rake notes    # Enumerate all annotations (use notes:optimize, :fixme, :todo for focus) 
rake notes:custom  # Enumerate a custom annotation, specify with ANNOTATION=CUSTOM 
rake rails:template  # Applies the template supplied by LOCATION=/path/to/template 
rake rails:update  # Update both configs and public/javascripts from Rails (or use just update:javascripts or update:configs) 
rake routes    # Print out all defined routes in match order, with names. 
rake secret    # Generate a crytographically secure secret key (this is typically used to generate a secret for cookie sessions). 
rake spec    # Run all specs in spec directory (excluding plugin specs) 
rake spec:acceptance # Run the code examples in spec/acceptance 
rake spec:controllers # Run the code examples in spec/controllers 
rake spec:helpers  # Run the code examples in spec/helpers 
rake spec:lib   # Run the code examples in spec/lib 
rake spec:mailers  # Run the code examples in spec/mailers 
rake spec:models  # Run the code examples in spec/models 
rake spec:rcov   # Run all specs with rcov 
rake spec:requests  # Run the code examples in spec/requests 
rake spec:routing  # Run the code examples in spec/routing 
rake spec:views   # Run the code examples in spec/views 
rake stats    # Report code statistics (KLOCs, etc) from the application 
rake test    # Runs test:units, test:functionals, test:integration together (also available: test:benchmark, test:profile, test:plugins) 
rake test:recent  # Run tests for recenttest:prepare/Test recent changes 
rake test:uncommitted # Run tests for uncommittedtest:prepare/Test changes since last checkin (only Subversion and Git) 
rake time:zones:all  # Displays all time zones, also available: time:zones:us, time:zones:local -- filter with OFFSET parameter, e.g., OFFSET=-6 
rake tmp:clear   # Clear session, cache, and socket files from tmp/ (narrow w/ tmp:sessions:clear, tmp:cache:clear, tmp:sockets:clear) 
rake tmp:create   # Creates tmp directories for sessions, cache, sockets, and pids 
+0

cuando ejecuto el rake -T, aparece ... ¿qué raíles está ejecutando? – thatmiddleway

+0

Uso los rieles 3.0.1. En dos sistemas diferentes con dos proyectos diferentes. No aparece en ambos sistemas (consulte la salida completa en la publicación editada). – Zardoz

+0

Echa un vistazo a mi respuesta actualizada. –

Respuesta

79

Las tareas que no tienen una descripción no aparecerán.

EDITAR: Parece que DHH eliminó la descripción de Rails 3 para algunas tareas para 'reducir el ruido'. rake db: setup tiene una nota acerca de db: reset though.

http://github.com/rails/rails/commit/983815632cc1d316c7c803a47be28f1abe6698fb

+33

Como alguien aprendiendo Rails, he perdido mucho tiempo tratando de encontrar documentación buena y clara para las tareas de rake relacionadas con la migración de db. –

39

Puede utilizar rake -P | grep rake para mostrar los nombres de todas las tareas de Rake.

+0

Esto es exactamente lo que necesitaba. Agregué esto a mi bash_profile con el alias "raket" como tal: # Muestra todas las tareas de rake disponibles, incluidas las que no tienen descripciones. alias raket = "rake -P | grep rake" Funciona muy bien. ¡Gracias! –

61

También puede usar rake db -T -A para mostrar todas las tareas, incluso las no comentadas. Como referencia estos interruptores están haciendo lo siguiente:

-T, --tasks [PATTERN] Display the tasks (matching optional PATTERN) with 
         descriptions, then exit. 
-A, --all    Show all tasks, even uncommented ones (in combination 
         with -T or -D) 
+8

Esta debería ser la respuesta aceptada. –

+3

Tenga en cuenta que la opción -A (o --all) se agregó en Rake 10. – slothbear

+0

'rake -T -A' muestra todas las tareas. 'rake -T db -A' muestra todas las tareas que contienen' db' en el nombre de la tarea (posición de la nota de 'db' ** después de **' -T'). –

1

para el usuario de Windows, esto se hace -P rastrillo | buscar "rastrillo"

7

Como seguimiento de la respuesta de Thomas Obermüller, dado que el indicador -T toma un argumento posicional, para obtener solo las tareas del espacio de nombres 'db' (al menos con el rastrillo 10.0.3) debe hacer : rake -T db -A

Cuestiones relacionadas