Skip to content

feat(help): show version, command counts, and allowed/disabled builtins#181

Merged
julesmcrt merged 13 commits intomainfrom
jules.macret/Q/help-add-allowed_commands
Apr 16, 2026
Merged

feat(help): show version, command counts, and allowed/disabled builtins#181
julesmcrt merged 13 commits intomainfrom
jules.macret/Q/help-add-allowed_commands

Conversation

@julesmcrt
Copy link
Copy Markdown
Collaborator

@julesmcrt julesmcrt commented Apr 14, 2026

Summary

Depends on #183 (version package and release workflow). Target that PR first.

  • The help builtin now shows a header with the rshell version and builtin count
  • When commands are restricted, help shows a compact "Disabled builtins:" list and help --all shows both sections as full description tables
  • When all builtins are allowed and --all is used, shows "All builtins are allowed in this session."

Before / After

1. ./rshell --allowed-commands "rshell:echo,rshell:help,rshell:ls" -c 'help'

Only 3 builtins are allowed. Running help without --all.

Before:

echo  write arguments to stdout
help  display help for commands
ls    list directory contents

Run 'help <command>' for more information on a specific command.

After:

rshell 0.0.10 — 3 of 28 builtins enabled

echo  write arguments to stdout
help  display help for commands
ls    list directory contents

Disabled builtins: [, break, cat, continue, cut, exit, false, find, grep, head, ip, ping,
  printf, ps, sed, sort, ss, strings, tail, test, tr, true, uname, uniq, wc

Run 'help <command>' for more information on a specific command.

2. ./rshell --allowed-commands "rshell:echo,rshell:help,rshell:ls" -c 'help --all'

Only 3 builtins are allowed. Running help --all to see full descriptions for disabled builtins too.

Before:

help: unknown flag: --all

After:

rshell 0.0.10 — 3 of 28 builtins enabled

echo  write arguments to stdout
help  display help for commands
ls    list directory contents

Disabled builtins:
[         evaluate conditional expression
break     exit from a loop
cat       concatenate and print files
continue  continue a loop iteration
cut       remove sections from each line
exit      exit the shell
false     return unsuccessful exit status
find      search for files in a directory hierarchy
grep      print lines that match patterns
head      output the first part of files
ip        show network interface and routing information
ping      send ICMP echo requests to a network host
printf    format and print data
ps        report process status
sed       stream editor for filtering and transforming text
sort      sort lines of text files
ss        display socket statistics
strings   print printable character sequences
tail      output the last part of files
test      evaluate conditional expression
tr        translate or delete characters
true      return successful exit status
uname     print system information
uniq      report or omit repeated lines
wc        print newline, word, and byte counts

Run 'help <command>' for more information on a specific command.

3. ./rshell --allow-all-commands -c 'help'

All builtins are allowed. Running help without --all.

Before:

[         evaluate conditional expression
break     exit from a loop
...
wc        print newline, word, and byte counts

Run 'help <command>' for more information on a specific command.

After:

rshell 0.0.10 — All 28 builtins available

[         evaluate conditional expression
break     exit from a loop
...
wc        print newline, word, and byte counts

Run 'help <command>' for more information on a specific command.

4. ./rshell --allow-all-commands -c 'help --all'

All builtins are allowed. Running help --all.

Before:

help: unknown flag: --all

After:

rshell 0.0.10 — All 28 builtins available

[         evaluate conditional expression
...
wc        print newline, word, and byte counts

All builtins are allowed in this session.

Run 'help <command>' for more information on a specific command.

Test plan

  • All existing help tests updated and passing
  • New tests for header, --all flag, restricted "Disabled builtins:" output
  • Scenario tests assert full stdout (not just stdout_contains)
  • Full test suite passes (go test ./... — 43 packages, 0 failures)
  • Symbol analysis tests pass (new internal/version.Version added to allowlists)

🤖 Generated with Claude Code

@julesmcrt julesmcrt marked this pull request as ready for review April 14, 2026 15:07
@julesmcrt julesmcrt changed the title feat(help): show version, command counts, and allowed/not-allowed builtins feat(help): show version, command counts, allowed/not-allowed builtins, and automated release workflow Apr 14, 2026
julesmcrt and others added 2 commits April 14, 2026 18:37
Add internal/version package with a source constant as single source of
truth for the release version, overridable via ldflags for dev builds.
Update the Makefile to inject version + commit at build time via git
describe.

Add a GitHub Actions release workflow (workflow_dispatch) that
auto-computes the next version from the latest git tag. Pick
patch/minor/major from a dropdown and click Run — no version to type.
The workflow bumps the constant, commits, tags, and creates the release.
Access is gated by a "release" environment requiring reviewer approval.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ltins

The help builtin now displays:
- A header with the rshell version and builtin count summary
  ("All N builtins available" or "N of M builtins enabled")
- A compact "Not allowed:" list when commands are restricted
- With --all, full description tables for both allowed and
  not-allowed builtins
- When all builtins are allowed and --all is used, a confirmation
  message "All builtins are allowed in this session."

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@julesmcrt julesmcrt force-pushed the jules.macret/Q/help-add-allowed_commands branch from 4ee0b74 to cdc07cf Compare April 14, 2026 16:40
@julesmcrt julesmcrt changed the title feat(help): show version, command counts, allowed/not-allowed builtins, and automated release workflow feat(help): show version, command counts, and allowed/not-allowed builtins Apr 14, 2026
@julesmcrt julesmcrt changed the base branch from main to jules.macret/Q/release-workflow April 14, 2026 16:41
Comment thread builtins/help/help.go Outdated
Comment thread builtins/help/help.go Outdated
Address review feedback from matt-dz. Uses singular/plural
form based on the count.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Comment thread tests/scenarios/cmd/help/list_commands.yaml Outdated
Comment thread tests/scenarios/cmd/help/restricted_commands.yaml Outdated
Comment thread tests/scenarios/cmd/help/all_flag.yaml Outdated
Comment thread builtins/help/help.go Outdated
Address PR review feedback: reword --all flag description to "show all
builtins (including not allowed) with descriptions" and replace
stdout_contains with full stdout assertions in all three help scenario
tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@julesmcrt julesmcrt changed the title feat(help): show version, command counts, and allowed/not-allowed builtins feat(help): show version, command counts, and allowed/disabled builtins Apr 16, 2026
Base automatically changed from jules.macret/Q/release-workflow to main April 16, 2026 11:15
julesmcrt and others added 7 commits April 16, 2026 13:18
…dd-allowed_commands

# Conflicts:
#	.github/workflows/release.yml
#	internal/version/version.go
#	internal/version/version_test.go
Skip displaying the version when it is "dev" (the default for
development/test builds). Real version strings from tagged releases
or ldflags are still shown.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The version package on main uses debug.ReadBuildInfo() instead of
ldflags, so the VERSION/COMMIT ldflags in the Makefile are unnecessary.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Covers case 4 from the PR description: all builtins allowed with
--all flag, showing the "All builtins are allowed in this session."
message.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Group the four help listing tests by restricted/unrestricted with
an _all_flag suffix:
- list_commands       → unrestricted
- all_flag_unrestricted → unrestricted_all_flag
- restricted_commands → restricted
- all_flag            → restricted_all_flag

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
var Version = buildVersion() always overwrites ldflags at init time.
Switch to an empty var with an init() guard so -X ldflags take
precedence. Re-add the Makefile VERSION ldflag (without Commit,
which no longer exists).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Revert the "dev" suppression — always show the version string
regardless of its value. Restore Makefile and version.go to match
main.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Display as "rshell (v0.0.10)" or "rshell (dev)" instead of
"rshell v0.0.10".

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@AlexandreYang AlexandreYang added the verified/analysis Human-reviewed static analysis changes label Apr 16, 2026
@julesmcrt julesmcrt added this pull request to the merge queue Apr 16, 2026
Merged via the queue into main with commit 9684cfe Apr 16, 2026
34 checks passed
@julesmcrt julesmcrt deleted the jules.macret/Q/help-add-allowed_commands branch April 16, 2026 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

verified/analysis Human-reviewed static analysis changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants