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

Support for shebang #1181

Open
MikkelHJuul opened this issue Aug 2, 2021 · 2 comments
Open

Support for shebang #1181

MikkelHJuul opened this issue Aug 2, 2021 · 2 comments
Labels
FeatureRequest New feature or request tooling

Comments

@MikkelHJuul
Copy link

It would be neat (if one would like to use cue for scripting) to be able to run the file using syntax: cue <file> <name> just like one would call cue cmd <name> this allow for portable usage of cue using the linux builtin portable shebang syntax. ie. ./<file> <name> for calling a given command(<name>) in a file(<file>) if the file's first line is #!/usr/bin/env cue.

This requires the cue <file> <name> to validate the existence of command: <name>: #Command in the given .cue-file before defaulting to the current error message.

The installation of cue itself (as with any go programs) makes the non-portable shebang (#!/direct/path/to/cue cmd) not particularly useable. As it would be very unlikely to be able to "hit" the cue executable directly in any environment. Also the current implementation of cue cmd dissallow file-targetting.

It is therefore required that one uses the portable version shebang (#!/usr/bin/env cue) which unfortunately removes the possibility of the user script controlling the "second" argument (set to the file) when cmd/cue expects this to be a command argument (cmd).

The minimum implementation is simply: run cue without a command only a cue-file (whatever it's name), must comply to command: [<name>]: _, (uncertainty on which additional files to load, if any, package?).

There may be some uncertainty on the _tool.cue-suffix vs. package loading etc. in fact this is a possibility of moving away from that syntax completely, to use direct file references in stead of implicit cwd runtime environment "enrichment" via magically named *_tool.cue-files. it does however increase the call syntax to require the file when running, such that the required syntax is cue cmd <file> <name> == cue <file> <name> (should calling without a file fallback to cwd as it currently does?). however the direct file helps picking the package/dependencies (multiple packages in the same folder? disallow directory loading? target multiple files? how should this be done best?)

I know cue as a scripting language is not particularly a priority, this is only a nice to have, not a need to have.

@MikkelHJuul MikkelHJuul added FeatureRequest New feature or request Triage Requires triage/attention labels Aug 2, 2021
@myitcv
Copy link
Member

myitcv commented Aug 10, 2021

Interesting thought. I haven't given this a huge amount of thought (will come back to it), but I will note in passing that we have plans to replace cue cmd with cuerun, which might make a solution in this space more "natural".

@myitcv
Copy link
Member

myitcv commented Oct 26, 2021

Linking to #1325 for the cuerun proposal

@rogpeppe rogpeppe removed the Triage Requires triage/attention label Apr 13, 2022
@mpvl mpvl added the tooling label Apr 13, 2022
@myitcv myitcv added the zGarden label Jun 15, 2023
@mvdan mvdan removed the zGarden label Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FeatureRequest New feature or request tooling
Projects
None yet
Development

No branches or pull requests

5 participants