Skip to content

Commit 1f89580

Browse files
committed
feat(git): add async output handling for instance creation
1 parent 9029102 commit 1f89580

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

internal/cmd/git/instance/create/create.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,18 @@ func outputResult(p *print.Printer, model *inputModel, resp *git.Instance) error
153153
}
154154

155155
return p.OutputResult(outputFormat, resp, func() error {
156-
p.Outputf("Created instance %q with id %s\n", model.Name, utils.PtrString(model.Id))
156+
if resp == nil {
157+
return nil
158+
}
159+
operationState := "Created"
160+
if model.Async {
161+
operationState = "Triggered creation of"
162+
}
163+
id := utils.PtrString(model.Id)
164+
if resp.Id != nil {
165+
id = *resp.Id
166+
}
167+
p.Outputf("%s instance %q with id %s\n", operationState, model.Name, id)
157168
return nil
158169
})
159170
}

internal/cmd/git/instance/create/create_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func TestOutputResult(t *testing.T) {
194194
{
195195
name: "empty input",
196196
args: args{
197-
model: &inputModel{},
197+
model: fixtureInputModel(),
198198
resp: &git.Instance{},
199199
},
200200
wantErr: false,

0 commit comments

Comments
 (0)