-
Notifications
You must be signed in to change notification settings - Fork 261
Prompt to create directory when using -C/--cwd with non-existent path #6266
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: vhvb1989 <24213737+vhvb1989@users.noreply.github.com>
Co-authored-by: vhvb1989 <24213737+vhvb1989@users.noreply.github.com>
Co-authored-by: vhvb1989 <24213737+vhvb1989@users.noreply.github.com>
|
|
||
| // Add -C flag with the subdirectory path | ||
| targetDir := filepath.Join(parentDir, tt.subDir) | ||
| args := append([]string{"-C", tt.subDir}, tt.args...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vhvb1989 Does this work? I didn't know we supported a -C flag. I was under the impression that --cwd is the only option currently available.
| if !opts.NoPrompt { | ||
| // Prompt the user | ||
| defaultValue := true | ||
| confirm := ux.NewConfirm(&ux.ConfirmOptions{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
weikanglim
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vhvb1989 Thanks for getting this out quickly! I am very much in favor of supporting something along the lines of "initialize azd in a new directory" because that is quite useful. I am very much in favor of us landing a change that supports this.
I spent some thinking about this a little more, and I wonder if you would consider azd init <directory>, i.e. azd init my-app -t <template> as the way we'd communicate this to the user. I believe that may be shorter and nicer than the current proposal of azd init -t <template> --cwd <directory> --no-prompt and would provide a better DX.
I am also seeing that it makes azd init my-app a nicer gesture to initialize "my-app" project, but do it interactively.
I personally find the |
azd would default the project name to match the directory name here. The primary use case here is to document this very nicely in templates and first-time usage of azd docs: azd init my-app -t <template>
cd my-appor azd init my-app
cd my-appSee bun init for what this could look like for azd. |
|
That being said, I'm not opposed to having the functionality as you have proposed here as it doesn't stop us from adding a more streamlined entrypoint in the future. I have approved. |
|
Another related issue is #181 with some good commentary and proposed designs. Please review before landing on an implementation. |
Previously,
azdfailed immediately when-C/--cwdpointed to a non-existent directory. This required users to manually create directories before running commands likeazd init -t template -C ./new-folder.Changes
Modified
PersistentPreRunEincmd/root.go:os.Chdir--no-promptflagos.MkdirAllAdded test coverage:
parent/child/project)Usage
Fixes #3680
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
aka.ms/home/REDACTED/work/azure-dev/azure-dev/cli/azd/azd-test init -t azure-samples/todo-nodejs-mongo -C ./new-folder(dns block)/home/REDACTED/work/azure-dev/azure-dev/cli/azd/azd-test init -t azure-samples/todo-nodejs-mongo -C ./new-folder --no-prompt(dns block)/home/REDACTED/work/azure-dev/azure-dev/cli/azd/azd-test telemetry upload(dns block)westus-0.in.applicationinsights.azure.com/home/REDACTED/work/azure-dev/azure-dev/cli/azd/azd-test telemetry upload(dns block)/home/REDACTED/work/azure-dev/azure-dev/cli/azd/azd telemetry upload(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.