Skip to content

Commit 3de0732

Browse files
smorinclaude
andauthored
feat: add product improvements — version, aliases, auto-slug, wt-cd, wt-open, wt-reopen, --json, init, env vars (#14)
Major new features and CLI ergonomics improvements: - `wtf version` command (table-stakes for any CLI tool) - Command aliases: new, pub, pr, up, clean, ls, st, cd, open, reopen - Auto-detect SLUG from current worktree (no more typing slug every time) - `wtf wt-cd SLUG` — print worktree path for shell composition - `wtf wt-open SLUG` — open worktree in editor ($EDITOR/code/vim/nano) - `wtf wt-reopen SLUG` — recreate worktree from existing remote branch - `wtf init` — interactive config wizard for .worktreeflow.toml - `--json` global flag for machine-readable output (doctor, wt-list, wt-status) - `--open` flag on wt-new to open editor after creation - Environment variable overrides: WTF_BASE_BRANCH, WTF_DEBUG, WTF_DRY_RUN, etc. - Enhanced wt-list: last activity dates, stale worktree detection (30+ days), PR status - Centralized `_require_gh()` for consistent gh CLI prerequisite checks - Updated tutorial and quickstart with all new features - 30 new tests (158 total), all passing with clean lint https://claude.ai/code/session_01A1Z3oDtv65NzXVqYaSsn8G Co-authored-by: Claude <noreply@anthropic.com>
1 parent fd73bfe commit 3de0732

File tree

10 files changed

+1022
-106
lines changed

10 files changed

+1022
-106
lines changed

src/worktreeflow/cli.py

Lines changed: 239 additions & 66 deletions
Large diffs are not rendered by default.

src/worktreeflow/config.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,45 @@ def load_config(repo_root: Path | None = None) -> RepoSettings:
157157
setattr(RepoConfig, repo_config_attr, merged[toml_key])
158158

159159
return settings
160+
161+
162+
def generate_config(
163+
upstream_repo: str | None = None,
164+
base_branch: str = "main",
165+
feature_branch_prefix: str = "feat/",
166+
use_ssh: bool = True,
167+
auto_stash: bool = False,
168+
create_backup_branches: bool = True,
169+
default_draft_pr: bool = False,
170+
) -> str:
171+
"""
172+
Generate a .worktreeflow.toml config file content.
173+
174+
Args:
175+
upstream_repo: Upstream repo in owner/repo format.
176+
base_branch: Base branch name.
177+
feature_branch_prefix: Prefix for feature branches.
178+
use_ssh: Whether to use SSH URLs.
179+
auto_stash: Whether to auto-stash during updates.
180+
create_backup_branches: Whether to create backups.
181+
default_draft_pr: Whether to create PRs as drafts.
182+
183+
Returns:
184+
TOML file content as a string.
185+
"""
186+
lines = ["# worktreeflow configuration", "# See: https://github.com/smorinlabs/worktreeflow", ""]
187+
lines.append("[repo]")
188+
if upstream_repo:
189+
lines.append(f'upstream_repo = "{upstream_repo}"')
190+
lines.append(f'base_branch = "{base_branch}"')
191+
lines.append(f"use_ssh = {'true' if use_ssh else 'false'}")
192+
lines.append("")
193+
lines.append("[workflow]")
194+
lines.append(f'feature_branch_prefix = "{feature_branch_prefix}"')
195+
lines.append(f"auto_stash = {'true' if auto_stash else 'false'}")
196+
lines.append(f"create_backup_branches = {'true' if create_backup_branches else 'false'}")
197+
lines.append("")
198+
lines.append("[pr]")
199+
lines.append(f"default_draft_pr = {'true' if default_draft_pr else 'false'}")
200+
lines.append("")
201+
return "\n".join(lines)

0 commit comments

Comments
 (0)