From fa532873c4761e88b61dafbfea42ea981a68bb70 Mon Sep 17 00:00:00 2001 From: uzulla Date: Fri, 26 Jun 2026 09:34:05 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20shp=20-f=20=E3=81=A7=E3=82=82=E3=83=94?= =?UTF-8?q?=E3=83=83=E3=82=AB=E3=83=BC=E3=82=92=E8=A1=A8=E7=A4=BA=E3=81=97?= =?UTF-8?q?=E3=81=A6=20force=20attach=20=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit これまで `shp -f`(名前なし)は TUI を出さず cwd 由来名へ即 force attach していたが、名前を選択/新規作成してから force attach したいケースに対応 できなかった。-f を「attach 時に force を付ける」だけの意味とし、選択 UX は `shp` と共通化する。 - runPicker(force) に force を渡し、選択/作成したセッションへ force 付きで attach - `shp -f ` の明示名指定は従来どおり TUI 無しで直接 force attach - usage 文言を更新 --- cmd/shp/main.go | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/cmd/shp/main.go b/cmd/shp/main.go index dca7b0a..9497ee2 100644 --- a/cmd/shp/main.go +++ b/cmd/shp/main.go @@ -22,9 +22,9 @@ Usage: when available. Enter attaches or creates when no match is found. shp Attach to the given session name (no TUI). - shp -f Force-attach to a session named after the current - directory (no TUI). - shp -f Force-attach to the given session name. + shp -f Show the TUI picker (like plain shp) and + force-attach to the chosen/created session. + shp -f Force-attach to the given session name (no TUI). shp --print-name Print the session name generated from the current directory and exit. shp -h | --help Show this help. @@ -84,21 +84,13 @@ func run(args []string) error { return fmt.Errorf("too many arguments") } - // `shp -f` without a name: force-attach directly to the cwd-derived name, - // or the full-path fallback when the cwd yields none (home / root). - if force { - name, err := session.FromCwdOrFallback() - if err != nil { - return err - } - return shpool.Attach(name, true) - } - - // `shp` (no args, no -f): show picker with cwd-name as the default entry. - return runPicker() + // `shp` / `shp -f` (no name): show the picker with the cwd name as the + // default entry. `force` is carried through to the final attach, so + // `shp -f` lets the user pick/create a session and force-attaches to it. + return runPicker(force) } -func runPicker() error { +func runPicker(force bool) error { // Use the full-path fallback when the cwd yields no name (the home // directory itself or the filesystem root) so the picker always has a // default create-entry, just like any other directory, instead of @@ -123,5 +115,5 @@ func runPicker() error { } return err } - return shpool.Attach(picked, false) + return shpool.Attach(picked, force) }