Skip to content

Commit fcac127

Browse files
takemi-ohamaclaude
andcommitted
feat(list): list TUI を questionary 移行 + running 操作選択 + devbase rebuild 追加 (i30)
- devbase list の対話選択を simple-term-menu から questionary へ移行。 ↑長押し時の入力取りこぼし (連結エスケープシーケンス破棄) を構造的に解消。 - 番号 [1]-[9] ショートカットを廃止し、全項目に通し番号ラベル + 名前での インクリメンタル絞り込み (use_search_filter) へ刷新。 - running 中のプロジェクト選択時に「再起動(up)/再ビルド(rebuild)/停止(down)」を 選ぶサブメニューを追加 (非 running は従来どおり直接 up)。 - devbase rebuild コマンド新設 (docker compose build --no-cache 相当)。 project/container/トップレベル + wrapper name 解決 + bash/zsh 補完に登録。 - pyproject: simple-term-menu を questionary>=2.1 へ置換。 - tests: rebuild / running サブメニュー / questionary seam / 補完を追加・更新。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent d385fcf commit fcac127

14 files changed

Lines changed: 630 additions & 103 deletions

CHANGELOG.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,21 @@
55
## [Unreleased]
66

77
### Added
8-
- **`devbase list` の対話選択を TUI 化**しました。`simple-term-menu` 導入により、
9-
↑↓ の矢印キーで行移動、先頭 9 件は `1``9` の数字キーで即ジャンプ、`/`
10-
名前のインクリメンタル検索ができます。Enter で選択プロジェクトを `up` 起動し、
11-
Esc で中止します。非 TTY(パイプ/CI/リダイレクト)では従来どおりプレーンな
12-
一覧表示にフォールバックし、`simple-term-menu` 未導入環境では番号入力方式に
13-
フォールバックします(macOS / Linux 対応)。
8+
- **`devbase list` の対話選択を TUI 化**しました。`questionary` 導入により、↑↓ の
9+
矢印キーで行移動、文字入力でプロジェクト名のインクリメンタル絞り込みができます
10+
(全項目に通し番号を表示)。Enter で決定、Ctrl-C で中止します。
11+
- **選択行が起動中 (running) の場合**は「再起動 (up) / 再ビルド (rebuild --no-cache) /
12+
停止 (down)」を選ぶサブメニューを表示します。それ以外 (stopped / unknown) は
13+
従来どおり `up` を起動します。
14+
- 非 TTY(パイプ/CI/リダイレクト)では従来どおりプレーンな一覧表示にフォールバック
15+
し、`questionary` 未導入環境では番号入力方式にフォールバックします。
16+
- 入力ライブラリを `simple-term-menu` から `questionary` (prompt_toolkit ベース) へ
17+
移行し、↑長押し時にスクロールが取りこぼされて遅くなる問題を解消しました。
18+
- **`devbase rebuild` コマンドを新設**しました。`docker compose build --no-cache` 相当で、
19+
キャッシュを無効化してプロジェクト (compose) イメージを作り直します。`devbase rebuild
20+
[name]` / `devbase project rebuild [name]` として任意のディレクトリから利用できます
21+
(`devbase list` の running サブメニューからも起動できます)。なお `devbase-base` まで
22+
作り直す 2 段ビルドは従来どおり `devbase build --no-cache` を使用してください。
1423
- **`devbase project` サブコマンド群を新設**しました (PLAN06)。CWD に依存せずプロジェクト名でコンテナ操作ができます。
1524
- `devbase project up/down/ps/logs/scale [name]` で、任意のディレクトリから `$DEVBASE_ROOT/projects/<name>` を対象に操作できます。名前解決はラッパー (`bin/devbase`) が対象ディレクトリへ `cd` してから実行するため、シェル実装の `build` を含む全操作が名前指定で成立します(呼び出し元シェルの作業ディレクトリは変わりません)。存在しない名前はエラーになり候補が提示されます。
1625
- `devbase project list``$DEVBASE_ROOT/projects/` 配下を `NAME` / `PLUGIN` / `STATUS` の一覧表示します。`PLUGIN` 列はシンボリックリンク先から解決するため、PLAN04 の同名衝突 suffix(例 `carmo.takemi`)が付いていても正しいプラグイン名を表示します。**TTY ではデフォルトで対話選択**になり、一覧から番号で選んだプロジェクトを `project up` で起動します。`--no-interactive``--plain` / `-P`)で一覧表示のみに切り替えられ、パイプ・リダイレクト・CI などの非 TTY 環境では自動的に一覧表示へフォールバックします(`--interactive` / `-i` は後方互換として引き続き受け付けます)。

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ devbaseは、Docker Composeを使った再現性の高い開発環境を提供
1515
- **データ永続化**: 名前付きボリュームでコンテナ再起動後もデータを保持
1616
- **スナップショット管理**: `/home/ubuntu` 共通ボリュームの増分バックアップ・復元・世代管理
1717
- **環境変数の自動収集**: `devbase env init`でAWS/Git/GCP認証情報を対話的に設定
18-
- **対話的なプロジェクト選択**: `devbase list` で矢印キー・番号・`/` 検索に対応した TUI メニューから起動対象を選べます
18+
- **対話的なプロジェクト選択**: `devbase list` で矢印キー移動・名前での絞り込みに対応した TUI メニューから起動対象を選べます。起動中のプロジェクトは「再起動 (up) / 再ビルド (rebuild) / 停止 (down)」を選択できます
19+
- **キャッシュ無効リビルド**: `devbase rebuild [name]``docker compose build --no-cache` 相当のイメージ再ビルドができます
1920

2021
## クイックスタート
2122

bin/devbase

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ run_python() {
199199
# Resolve abbreviated command to full command name via unique prefix matching
200200
resolve_command() {
201201
local input="$1"
202-
local commands="init status shell-rc project container ct env plugin pl snapshot ss up down login build ps scale list help"
202+
local commands="init status shell-rc project container ct env plugin pl snapshot ss up down login build rebuild ps scale list help"
203203
local matches=()
204204
for cmd in $commands; do
205205
[[ "$cmd" == "$input"* ]] && matches+=("$cmd")
@@ -331,8 +331,8 @@ _DEVBASE_ARGS=("${@:2}")
331331
# そのプロジェクトへ切り替えてから (cd 済みの状態で) コマンドを実行すること。
332332
# こうすれば name 解決トークンを与える必要がなくなり、index/image/service を
333333
# 意図どおり渡せる。
334-
_PROJECT_NAME_SUBCOMMANDS=" up down ps logs scale "
335-
_NAME_RESOLVABLE_SHORTCUTS=" up down ps scale login build "
334+
_PROJECT_NAME_SUBCOMMANDS=" up down ps logs scale rebuild "
335+
_NAME_RESOLVABLE_SHORTCUTS=" up down ps scale login build rebuild "
336336
case "$_resolved_cmd" in
337337
project|container|ct)
338338
# `ct` は container の alias (cli.py: add_parser('container', aliases=['ct']))。
@@ -355,7 +355,7 @@ case "$_resolved_cmd" in
355355
# Python-implemented commands
356356
--version|-V)
357357
run_python "$@" ;;
358-
init|status|shell-rc|project|container|ct|env|plugin|pl|snapshot|ss|up|down|login|ps|scale|list)
358+
init|status|shell-rc|project|container|ct|env|plugin|pl|snapshot|ss|up|down|login|ps|scale|rebuild|list)
359359
run_python "${_resolved_cmd}" "${_DEVBASE_ARGS[@]}" ;;
360360
# Shell-implemented commands
361361
build) cmd_build "${_DEVBASE_ARGS[@]}" ;;

etc/_devbase

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ _devbase() {
6464
'down:Stop containers (shortcut)'
6565
'login:Login to container (shortcut)'
6666
'build:Build container images'
67+
'rebuild:Rebuild images without cache (shortcut)'
6768
'ps:Show container status (shortcut)'
6869
'scale:Scale containers online (shortcut)'
6970
'list:List projects (shortcut)'
@@ -78,6 +79,7 @@ _devbase() {
7879
'logs:Show container logs'
7980
'scale:Scale containers online'
8081
'build:Build container images'
82+
'rebuild:Rebuild images without cache (docker compose build --no-cache)'
8183
'list:List projects (NAME / PLUGIN / STATUS)'
8284
)
8385

@@ -89,6 +91,7 @@ _devbase() {
8991
'logs:Show container logs'
9092
'scale:Scale containers online'
9193
'build:Build container images'
94+
'rebuild:Rebuild images without cache (docker compose build --no-cache)'
9295
)
9396

9497
env_subcommands=(
@@ -134,8 +137,8 @@ _devbase() {
134137
login)
135138
_values 'index' 1 2
136139
;;
137-
# トップレベルシノニム: up/down/ps/scale は [name] を取るためプロジェクト名を補完。
138-
up|down)
140+
# トップレベルシノニム: up/down/ps/scale/rebuild は [name] を取るためプロジェクト名を補完。
141+
up|down|rebuild)
139142
_devbase_project_names
140143
;;
141144
ps)
@@ -158,7 +161,7 @@ _devbase() {
158161
;;
159162
project)
160163
case "$words[3]" in
161-
up|down)
164+
up|down|rebuild)
162165
_devbase_project_names
163166
;;
164167
login)

etc/devbase-completion.bash

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ _devbase_completions() {
3131
cword=$COMP_CWORD
3232
}
3333

34-
local commands="init status shell-rc project container ct env plugin pl snapshot ss up down login build ps scale list help"
34+
local commands="init status shell-rc project container ct env plugin pl snapshot ss up down login build rebuild ps scale list help"
3535
# project / container は同じサブコマンド群 (container は非推奨だが補完は維持)。
36-
local project_subcommands="up down ps login logs scale build list"
37-
local container_subcommands="up down ps login logs scale build"
36+
local project_subcommands="up down ps login logs scale build rebuild list"
37+
local container_subcommands="up down ps login logs scale build rebuild"
3838
local env_subcommands="init sync list set get delete edit project export import"
3939
local plugin_subcommands="list install uninstall update info sync repo"
4040
local repo_subcommands="add remove list refresh"
@@ -49,9 +49,9 @@ _devbase_completions() {
4949
login)
5050
COMPREPLY=($(compgen -W "1 2" -- "$cur"))
5151
;;
52-
# トップレベルシノニム: up/down/scale は [name] を取るため
52+
# トップレベルシノニム: up/down/scale/rebuild は [name] を取るため
5353
# プロジェクト名を補完する (login=index / build=image は対象外)。
54-
up|down|scale)
54+
up|down|scale|rebuild)
5555
COMPREPLY=($(compgen -W "$(_devbase_project_names)" -- "$cur"))
5656
;;
5757
# ps は [name] と -a フラグの両方を取る (project ps と同じ挙動)。
@@ -96,7 +96,7 @@ _devbase_completions() {
9696
# project subcommand arguments (推奨グループ)
9797
if [ "$group" = "project" ]; then
9898
case "$prev" in
99-
up|down)
99+
up|down|rebuild)
100100
COMPREPLY=($(compgen -W "$(_devbase_project_names)" -- "$cur"))
101101
;;
102102
login)

0 commit comments

Comments
 (0)