-
-
Notifications
You must be signed in to change notification settings - Fork 580
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
Add global --root and --project flags to allow ddev to run in any directory #2128
Comments
Most ddev commands take the project as the first argument. For example Does that solve your problem? |
Not really, no. Primarily because it has to be the first arg after the command name. Some of my most frequently used commands don't allow that, specifically because they take their own arguments after the command name:
|
|
I get what you're saying, but if you already have a project with a name, then it should work just fine (does in my example above). If you wanted to create a new project (initializing config), then yes, a
No, because the custom command only exists in a specific project. One would have to first navigate to the project and then run the custom command. What I'm proposing here is that if a
They should all have one. That's the point I'm trying to make. Choosing which command has this option and which doesn't would be very confusing. Actually, I can see use cases for both:
|
A global flag is a reasonable thing. I don't see how it would hurt anything, and could really help. |
I really think both flags should be added and I think it makes sense to do them at the same time. |
This is a great idea. I ran into a technical challenge when trying it out, chicken-and-egg problem of when commands and flags are created. Asked about it in https://stackoverflow.com/questions/61142797/dynamic-creation-of-cobra-commands-based-on-directory-specified-by-flag |
Just came across this when I was starting to implement #4416 (comment) - these are basically two ways of handling the same (or at least a related) problem, and they conflict with each other. Looks like we have two options here:
1 is obviously easier, and leaves the list of commands when you run Happy to do either, but I don't want to start working on it without some input since these options are mutually exclusive. |
IIRC this issue is about running a project command from anywhere and providing context to it about the project it's to run in, it's not about global commands. And it's intended for all (project-level) commands, not just custom commands. |
OH! I don't think that would be practical, since you'd have to either parse the flag before the command you're using it with exists (which I don't think is possible), or include all project commands for all projects as though they're global (which would be messy at best and collision hell at best). That said - I do think doing this for global service commands might have some merit. Do you have any thoughts on that front? |
Can you give an example how you'd use it with global commands? I don't immediately understand how that would help, given the work you've already done. I haven't thought about it carefully, but as fancy as this stuff is I'd be surprised if we couldn't capture the flag processing early. And you'd be the one to do it! |
The basic idea behind this feature request is for DDEV go operate like the Drupal CLI |
The work I've already done only applies to global host commands - and it doesn't provide any information about projects e.g. through a flag or argument. This would be a way to a) provide that extra context, and b) allow global service commands to also be used from anywhere - basically the exact same thing this issue is suggesting, except only for global commands, not project-level commands. That said, if what you want is a flag that gets pre-processed and dynamically sets up the commands for the project named in the flag.... I can try to figure out a way to do that. At worst I'll be able to show why it isn't possible, at best we'll both get a way to do what we're trying to do 👍 |
I've created #5863 to tackle this |
Is your feature request related to a problem? Please describe.
Remote ddev server
Describe the solution you'd like
The ability to run ddev commands for a specific project without having to know the path of the project, navigating to the project path and then executing command in that directory.
Currently, I'm using a very complicated jq command to extract the
approot
of a project name. This requires actually installing jq and proxying the commands via the following script (ddev-proxy):This allows me to setup an alias on my local:
Then I can simply execute the following on my local:
What I would prefer, is to not have to proxy the commands via a custom script at all and instead call ddev directly:
Describe alternatives you've considered
Clearly, the above technically works... but it's just more work than is necessary to extract the approot and execute a command for that project. It would be nice if this was just supported natively.
Additional context
None
The text was updated successfully, but these errors were encountered: