-
Notifications
You must be signed in to change notification settings - Fork 292
Expand file tree
/
Copy pathcommands.go
More file actions
48 lines (39 loc) · 1.16 KB
/
commands.go
File metadata and controls
48 lines (39 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package cmd
import (
"fmt"
"github.com/azure/azure-dev/cli/azd/extensions/azure.provisioning/internal/project"
"github.com/azure/azure-dev/cli/azd/pkg/azdext"
"github.com/spf13/cobra"
)
func NewRootCommand() *cobra.Command {
root := &cobra.Command{
Use: "provisioning",
Short: "Azure.Provisioning C# CDK extension",
}
root.AddCommand(newListenCommand())
return root
}
func newListenCommand() *cobra.Command {
return &cobra.Command{
Use: "listen",
Short: "Starts the extension and listens for events.",
RunE: func(cmd *cobra.Command, args []string) error {
ctx := azdext.WithAccessToken(cmd.Context())
azdClient, err := azdext.NewAzdClient()
if err != nil {
return fmt.Errorf("failed to create azd client: %w", err)
}
defer azdClient.Close()
host := azdext.NewExtensionHost(azdClient).
WithImporter("csharp", func() azdext.ImporterProvider {
return project.NewCSharpImporterProvider(azdClient)
})
if err := host.Run(ctx); err != nil {
return fmt.Errorf("failed to run extension: %w", err)
}
return nil
},
}
}