roots / trellis-cli

A CLI to manage Trellis projects
https://roots.io/trellis/
MIT License
166 stars 25 forks source link

Feature Request: Allow parameters to be passed with trellis vm shell #377

Closed robrecord closed 1 year ago

robrecord commented 1 year ago

Terms

Summary

As I understand it, trellis vm shell is a wrapper for limactl shell <project_name>. Until recently, the lima docs incorrectly reported the order of parameters. Now it's limactl shell [<options>] <project_name> [<command>]. Could it be possiblt to allow trellis-cli to pass options such as --workdir, or even set them automatically?

So trellis vm shell would be a wrapper for limactl shell --workdir /srv/www/<project_name>/current <project_name> and would include any user-specified extra params before the , and anything else after a --.

Hope that makes sense?

Motivation

Why are we doing this?

  1. allow directly CDing into correct dirctory
  2. allow user passing of params
  3. allow separation between params and command
  4. currently it is impossible to pass any parameters (such as workdir) to limactl

What use cases does it support?

Better use of SSH into VM

What is the expected outcome?

More control and convenience

Potential conflicts / foreseeable issues

Additional Context

https://github.com/lima-vm/lima/pull/1444

with trellis:

❯ trellis vm shell --workdir /srv/www/example.com/current
Running command => limactl shell example.com --workdir /srv/www/example.com/current
bash: line 1: cd: /Users/me/Code/Projects/Sites/example.com/trellis: No such file or directory
bash: line 1: cd: /Users/me: No such file or directory
/bin/bash: --: invalid option

with limactl:

❯ limactl shell --workdir /srv/www/example.com/current example.com
me@lima-example:/srv/www/example.com/current$
swalkinshaw commented 1 year ago

I had planned on setting --workdir to either /srv/www/example.com or /srv/www/example.com/current automatically as a default. We could also let people override that in the CLI config file.

Additionally, I do think a flag override would be helpful too.

I've also thought about just mounting those two default dirs so lima doesn't complain; it's annoying they don't a way to avoid that. I could always contribute an upstream fix 🤷‍♂️

robrecord commented 1 year ago

Thank you for this!