Skip to content

Skip non-executable files, add .source suffix convention (#53)#63

Merged
toumorokoshi merged 2 commits into
mainfrom
53-skip-non-executable-files
Apr 8, 2026
Merged

Skip non-executable files, add .source suffix convention (#53)#63
toumorokoshi merged 2 commits into
mainfrom
53-skip-non-executable-files

Conversation

@toumorokoshi

@toumorokoshi toumorokoshi commented Apr 7, 2026

Copy link
Copy Markdown
Owner

Related: #53

Summary

Implements the design proposed in #53 (comment). Only files with the executable bit set are now recognized as tome commands, and a new .source suffix convention replaces the # SOURCE header for sourceable scripts.

This makes it possible to include READMEs, data files, and library scripts in a tome directory without them appearing in help output or tab completion.

Changes

  • script.rs: is_tome_script now takes a &Path and checks: (1) no dot-prefix, (2) .source suffix files are always valid, (3) otherwise the file must have the executable bit. Added resolve_source_path for transparent .source file lookup. Removed # SOURCE header parsing — source detection is now purely filename-based.
  • directory.rs: Passes full path to is_tome_script. Strips .source suffix from command names so foo.source appears as command foo.
  • finder.rs: Uses resolve_source_path to find both foo and foo.source when resolving commands.
  • complete.rs: Uses new is_tome_script(&path) for filtering, strips .source suffix from completion candidates, uses resolve_source_path for file lookup.
  • Example files: Renamed source_examplesource_example.source, source_example_fishsource_example_fish.source, use-arguse-arg.source, navigate_directorynavigate_directory.source. Added non_executable_file test fixture. Removed # SOURCE headers from all files.
  • Tests: Updated all tests for new paths and expectations. Replaced # SOURCE header tests with .source suffix tests.
  • Docs: Updated authoring-scripts.md and directories.md to document the executable-bit requirement and .source suffix convention.

Breaking Changes

  • Files without the executable bit are no longer recognized as commands (unless they have a .source suffix)
  • The # SOURCE header comment is no longer recognized; use the .source file suffix instead

@toumorokoshi
toumorokoshi force-pushed the 53-skip-non-executable-files branch 2 times, most recently from e6dc8d7 to bd176b9 Compare April 7, 2026 05:33
- Only files with the executable bit set are recognized as tome commands
- Files with a .source suffix are treated as sourceable scripts (no exec bit needed)
- The .source suffix replaces the # SOURCE header comment
- Dot-prefixed directories continue to be ignored
- Non-executable files (READMEs, data files, libraries) are now excluded from
  help output and tab completion automatically

Breaking changes:
- Scripts that were previously recognized but lack the executable bit will no
  longer appear as commands
- The # SOURCE header is no longer recognized; use the .source suffix instead

Closes #53
@toumorokoshi
toumorokoshi force-pushed the 53-skip-non-executable-files branch from bd176b9 to 40bb7fc Compare April 7, 2026 05:40
@toumorokoshi
toumorokoshi marked this pull request as ready for review April 8, 2026 05:03
@toumorokoshi
toumorokoshi merged commit baa97ed into main Apr 8, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant