numtide / devshell

Per project developer environments
https://numtide.github.io/devshell/
MIT License
1.23k stars 88 forks source link

external script support for commands #281

Open justinabrahms opened 12 months ago

justinabrahms commented 12 months ago

Is your feature request related to a problem? Please describe.

I'd like syntax highlighting for bash scripts and similar, which I don't get in TOML.

Also, I'd like it if the scripts were invokable by people who don't want to use nix, provided they have a properly configured environment.

Describe the solution you'd like

instead of command = '''...''', I'd like commandFile = './scripts/foo.sh'

Describe alternatives you've considered

perhaps some toml import synatx something or other, but that seems too complex.

Additional context

deemp commented 8 months ago

IDK what's you use case. Please, describe it in more details.

Currently, you can create a script file:

cat > hello.sh <<EOF
printf "hello!\n"
EOF
chmod +x hello.sh

Then, in devshell.toml (this repo uses this file for the default devshell), create a command that runs that file:

# ...
[devshell]
# ...
[[commands]]
help = "prints hello"
name = "hello"
command = "$PRJ_ROOT/hello.sh"
# ...

Now, you can run

$ hello
hello!
justinabrahms commented 8 months ago

I think that will work for me.

I'm not sure what else to say about the use cases.

  1. I want syntax highlighting so I can see errors.
  2. Some people on my team don't want to use nix. They should be able to invoke the scripts too.
zimbatm commented 8 months ago

In that case, the best thing is to put the scripts in a ./bin or ./scripts folder in your project. Then only use Nix and devshell to bring the dependencies (eg: curl, jq, ...) as @deemp described.