toumorokoshi / tome

convert any directory of scripts into your own fully-featured command.
MIT License
36 stars 2 forks source link

(feature request) Include a flag for determining what scripts to include #53

Open zph opened 6 months ago

zph commented 6 months ago

Use case:

Feature:

ie:

# Default and current behavior
eval "$(tome init my-commands --include=all ~/my-scripts bash)"

# New extension
eval "$(tome init my-commands --include=executables ~/my-scripts bash)"

@toumorokoshi Is this something you'd accept as a patch under the design conditions of "does not break default backwards compatibility"?

zph commented 5 months ago

Ok, I've been thinking about this and I prototyped a simpler solution that those implicit behaviors as follows:

  1. Use a .tomeignore file in the root directory to control whether files show up in help and in tab completions
  2. Syntax is the .gitignore syntax and I used a rust gitignore parser/checker library.

I think it's a more elegant approach that solves the following usability issues:

  1. Can replace current usage of .tomeignore as a file in a folder to ignore that one folder
  2. Enables users to use a familiar file syntax to determine what to ignore
  3. Does not rely on implicit behaviors (ignore files with leading dot) or only show files that are executable

If you also like this approach and want it contributed back, let me know 👍

toumorokoshi commented 5 months ago

Hey! thanks for the suggestion.

If there's a strong need for custom ignoring of files - I think a gitignore-style file with glob matches makes sense. And happy to accept a PR!

FYI all scripts and files with a leading dot are ignored today. Does that not work for your use case?