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 other task languages #42

Closed
dschep opened this issue Feb 23, 2023 · 10 comments · Fixed by #84
Closed

Support for other task languages #42

dschep opened this issue Feb 23, 2023 · 10 comments · Fixed by #84
Labels
enhancement New feature or request

Comments

@dschep
Copy link

dschep commented Feb 23, 2023

Many markdown renderers, including Github&Gitlab Flavored markdown support specifying a language for syntax highlighting.

It'd be awesome to use this to specify a different shell/interpreter for tasks

eg,

```bash
cp foo bar
```

will explicitly run bash

and

```python
import json
print(json.load(open('foobar.json')))
```

would invoke python instead

@joerdav
Copy link
Owner

joerdav commented Feb 24, 2023

I think this is an interesting idea, and intuitive. The only concern I have is whether this is something that makes sense in xc, being a task runner equivelant to Make or npm run but more discoverable. Welcome your thoughts on some real use cases.

For example currently my main use for xc is the document things such as how to deploy a project, or how to build it.

@waldyrious
Copy link
Contributor

waldyrious commented Feb 24, 2023

a task runner equivelant to Make or npm run but more discoverable

A bit off topic, but I have to say that this description is IMO much clearer than the current one in the README:

a task runner designed to maximise convenience, and minimise complexity.

Would a PR changing the latter to (some variant of) the former be considered?

@joerdav
Copy link
Owner

joerdav commented Feb 24, 2023

@waldyrious I'm open to contributions, if you open a PR we can spitball some alternatives. It's hard to explain exactly what something does in such few words, but it's valuable once you get it right!

@dschep
Copy link
Author

dschep commented Feb 24, 2023

I've all too often had a task runner (npm or make) just call a python script, so implementing this would remove that intermediary step.

For example... does this repo implement update-nix.sh as a script called by xc because interp doesn't implement all the shell/bash features it requires? If so and if we(I say we, bc I'd be willing to try and implement this if you like the idea) were to implement this, you could remove that script and inline it into README.md with a ```bash gate to have it invoke real bash.

@joerdav
Copy link
Owner

joerdav commented Feb 27, 2023

@dschep I'm thinking on this, and I'm in two minds about it. The purpose of xc is so that your "useful commands runner" and the documentation for them are stored in the same place.

It also means that even if xc is not installed someone could find use in the Tasks section. Say someones task contained a python script, would they not have to copy it out into a file then run it, rather than copying it straight into their shell?

Would defining a whole python script in a task, be too verbose?

Just jotting down my thoughts. I'll keep this issue open, for commenting.

@joerdav joerdav added the enhancement New feature or request label Feb 27, 2023
@waldyrious
Copy link
Contributor

Just a small note from someone casually following the discussion: since the rendered markdown only uses the language specification for syntax highlighting, would it make sense to require shebangs (or for tasks defined in languages other than bash, just to make things explicit in case xc isn't available and people want to run the commands manually (so they'll know which interpreter to invoke)?

#!/usr/bin/env python 

print("foo")

Note that this would enable straight copy-paste into a terminal if the #! is not copied, i.e.

/usr/bin/env python

print("foo")

(But it does feel pretty hacky/brittle...)

@joerdav
Copy link
Owner

joerdav commented Feb 28, 2023

@waldyrious It seems a better approach to drive which interpreter is used from the shebang line, more discoverable, but like you say I still think that it detriments the experience of someone coming to the README without a knowledge of xc, apposed to if it was a smaller task that calls a python script directly.

@dschep
Copy link
Author

dschep commented Feb 28, 2023

I like that idea too @waldyrious !

@jasonmorganson
Copy link

Just uses that method: https://just.systems/man/en/chapter_40.html

@joerdav
Copy link
Owner

joerdav commented May 2, 2023

Started tinkering on this at https://github.com/joerdav/xc/tree/other-languages

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants