Skip to content

Commit 0b15e13

Browse files
authored
[CLI] Made generate ssh-config work without config file (#826)
## Summary Title says it ## How was it tested? run `./devbox generate ssh-config` in an empty directory.
1 parent a9c797d commit 0b15e13

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

internal/boxcli/generate.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,19 @@ func sshConfigCmd() *cobra.Command {
118118
}
119119

120120
func runGenerateCmd(cmd *cobra.Command, args []string, flags *generateCmdFlags) error {
121+
// ssh-config command is exception and it should run without a config file present
122+
if cmd.Use == "ssh-config" {
123+
_, err := cloud.SSHSetup(flags.githubUsername)
124+
if err != nil {
125+
return err
126+
}
127+
return nil
128+
}
129+
121130
path, err := configPathFromUser(args, &flags.config)
122131
if err != nil {
123132
return err
124133
}
125-
126134
// Check the directory exists.
127135
box, err := devbox.Open(path, os.Stdout)
128136
if err != nil {
@@ -137,11 +145,6 @@ func runGenerateCmd(cmd *cobra.Command, args []string, flags *generateCmdFlags)
137145
return box.GenerateDockerfile(flags.force)
138146
case "direnv":
139147
return box.GenerateEnvrc(flags.force, "generate")
140-
case "ssh-config":
141-
_, err := cloud.SSHSetup(flags.githubUsername)
142-
if err != nil {
143-
return err
144-
}
145148
}
146149
return nil
147150
}

0 commit comments

Comments
 (0)