Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow inline recipe comments to be anywhere in the file #2949

Open
CyberShadow opened this issue Jul 10, 2024 · 0 comments
Open

Allow inline recipe comments to be anywhere in the file #2949

CyberShadow opened this issue Jul 10, 2024 · 0 comments

Comments

@CyberShadow
Copy link
Member

Currently, Dub requires that inline recipes (for single-file mode) are at the top of the file, directly following the shebang line. Trying to place them somewhere else results in:

Error The source file must start with a recipe comment.

I think it would make sense to relax this restriction, and allow them to occur anywhere in the file, for the following reasons:

  1. The recipe is an implementation detail, and it's not very useful as one of the first things a reader would want to see at the top of the file.

    It would be more useful to start the file with a comment or documentation block, describing what the program does, and an overview of the program.

  2. Dub is not the only tool that benefits from embedding its own machine-readable information in source files.

    Some other examples of this are:

    • Vim modelines
    • Emacs file-local variables
    • nix-shell configuration lines

    Fortunately, none of these other tools require that their information is at the top of the file. However, if any of these tools did also require that their information had to be placed at the top of the file, then it would be impossible to use them alongside Dub. So, Dub should play nice as well and not expect that it and only it deserves the top-most place in the source file.

An example program that would benefit from this improvement: https://github.com/CyberShadow/misc/blob/eb1cd77866fc0bcad37d9513d611b0de49357695/git-copy-revs.d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant