`generate action` ignores `--url` and `--http`: the route always comes from the action name
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 78/100
Línea de trabajo
El issue identifica las declaraciones de opciones de generate action y la transferencia de #call, además del manejo de route_url y route_http por parte del generador. Lee esos puntos de entrada y comprueba cómo llegan al generador los nombres de las opciones analizadas. Se considera terminado cuando las opciones documentadas --url y --http producen la ruta esperada en config/routes.rb.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
hanami generate action --help documents --url and --http, with this example:
hanami generate action sessions.new --url=/login
# => get "/login", to: "sessions.new"
With hanami-cli 3.0.0 both options are accepted without error and have no effect. The route written to config/routes.rb is derived from the action name alone:
$ bundle exec hanami generate action sessions.probe --url=/login
Created app/actions/sessions/probe.rb
Created app/views/sessions/probe.rb
Created app/templates/sessions/probe.html.erb
Created spec/actions/sessions/probe_spec.rb
# config/routes.rb
get "/sessions/probe", to: "sessions.probe"
--http is ignored the same way:
$ bundle exec hanami generate action posts.create --http=delete
# config/routes.rb
post "/posts", to: "posts.create"
Expected: get "/login", to: "sessions.probe" and delete "/posts", to: "posts.create", as documented.
Where it seems to come from
The command declares the options with an alias:
option :url, as: :url_path, required: false, type: :string, desc: "Action URL path"
option :http, as: :http_method, required: false, type: :string, desc: "Action HTTP method"
and #call takes url_path: nil, http_method: nil, **opts, which it forwards to the generator, where route_url / route_http do honour them.
As far as I can tell, as: is not something dry-cli knows about. In dry-cli 1.4.1, Dry::CLI::Option#initialize(name, options = {}) stores the extra keys without reading :as, and the parser assigns parsed values by option.name.to_sym (lib/dry/cli/parser.rb, parsed_options[option.name.to_sym] = value). So --url=/login arrives in #call as url: "/login" inside **opts, url_path stays nil, and the generator falls back to the name-derived route. Same for --http / http_method.
The option declarations are unchanged on main, and I could not find :as handling in dry-cli's main either, so I believe this is still present after the Dry CLI 2.0 move (read only, not executed).
Environment: hanami-cli 3.0.0, hanami 3.0.1, dry-cli 1.4.1, Ruby 3.4.6, macOS.
- Lenguaje dominante
- Ruby
- Estrellas
- 33
- Forks
- 57
- Merge medio
- 1 d 6 h
- PR fusionados (30 d)
- 9
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de hanami/hanami-cli
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
hanami/hanami-cli#485 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
hanami/hanami-cli#484 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
hanami/hanami-cli#453 ·
Los mantenedores suelen responder en 1 día
-
`generate struct` should generate the app/slice base class too, if it doesn't yet existQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
hanami/hanami-cli#450 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 65/100
hanami/hanami-cli#418 ·
Los mantenedores suelen responder en 1 día
Todos los issues de hanami/hanami-cli
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
open-feature/ruby-sdk-contrib#340 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
zold-io/wts.zold.io#651 ·
Los mantenedores suelen responder en 1 día
-
good first issue help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 87/100
erkamyaman/rust-anything#788 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 74/100
TheOdinProject/curriculum#31579 ·
Los mantenedores suelen responder en 1 día