Skip to content

Commit af163be

Browse files
authored
Add temporalctx help command (#9)
1 parent 21a7ca7 commit af163be

3 files changed

Lines changed: 32 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ temporalctx staging # switch to "staging" context
8181
temporalctx - # switch to previous context
8282
temporalctx -c # print current context
8383
temporalctx edit # open config in $EDITOR
84+
temporalctx help # show command help
8485
tctx # alias for temporalctx
8586
```
8687

temporalctx.plugin.zsh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,20 @@ _temporalctx_edit_config() {
231231
${=editor_cmd} "$config_file"
232232
}
233233

234+
_temporalctx_help() {
235+
cat <<'EOF'
236+
Usage:
237+
temporalctx interactive picker (fzf)
238+
temporalctx <context> switch to context
239+
temporalctx - switch to previous context
240+
temporalctx -c print current context
241+
temporalctx edit open config in $VISUAL/$EDITOR
242+
temporalctx start start local dev server
243+
temporalctx stop stop local dev server
244+
temporalctx help show this help
245+
EOF
246+
}
247+
234248
_temporalctx_start_local_server() {
235249
local no_overmind pid_file pid socket procfile
236250
no_overmind="${1:-0}"
@@ -375,6 +389,9 @@ temporalctx() {
375389
"")
376390
_temporalctx_pick_context
377391
;;
392+
help|-h|--help)
393+
_temporalctx_help
394+
;;
378395
start)
379396
if [[ "$2" == "--no-overmind" ]]; then
380397
no_overmind=1

tests/temporalctx_plugin_test.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,20 @@ assert_contains "$visual_args" "$cfg" "editor should receive config file path"
106106
[[ ! -f "$fallback_log" ]] || fail "EDITOR fallback should not run when VISUAL is set"
107107
log "case passed: edit subcommand"
108108

109+
# Test: help output via subcommand and flag.
110+
log "case: help output"
111+
out="$(TEMPORAL_CONFIG="$cfg" zsh -c '
112+
source "'$REPO_ROOT'/temporalctx.plugin.zsh"
113+
echo "-- help --"
114+
temporalctx help
115+
echo "-- --help --"
116+
temporalctx --help
117+
')"
118+
assert_contains "$out" "Usage:" "help output should include usage header"
119+
assert_contains "$out" "temporalctx <context>" "help output should describe context switching"
120+
assert_contains "$out" "temporalctx help" "help output should describe help command"
121+
log "case passed: help output"
122+
109123
# Test: alias + local dev server start/stop via PID file.
110124
log "case: tctx alias and local dev server lifecycle"
111125
out="$(PATH="$tmp_root/bin:$PATH" TEMPORAL_CONFIG="$cfg" zsh -c '

0 commit comments

Comments
 (0)