`generate action` ignores `--url` and `--http`: the route always comes from the action name
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Issueでは、generate action オプションの宣言と #call による引き渡しに加え、ジェネレーターでの route_url と route_http の処理が示されています。これらのエントリーポイントを読み、解析されたオプション名がどのようにジェネレーターに渡るかを確認してください。ドキュメントに記載された --url と --http オプションによって、config/routes.rb に期待される route が生成されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- Ruby
- スター
- 33
- フォーク
- 57
- 平均マージ
- 1日 6時間
- マージ済み PR(30日)
- 9
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
hanami/hanami-cli のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
hanami/hanami-cli#485 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
hanami/hanami-cli#484 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
hanami/hanami-cli#453 ·
メンテナーはふだん 1 日以内に返信
-
`generate struct` should generate the app/slice base class too, if it doesn't yet exist再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
hanami/hanami-cli#450 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 65/100
hanami/hanami-cli#418 ·
メンテナーはふだん 1 日以内に返信
hanami/hanami-cli の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
open-feature/ruby-sdk-contrib#340 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
zold-io/wts.zold.io#651 ·
メンテナーはふだん 1 日以内に返信
-
good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 87/100
erkamyaman/rust-anything#788 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 74/100
TheOdinProject/curriculum#31579 ·
メンテナーはふだん 1 日以内に返信