forked from Azure/azure-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaction.go
36 lines (29 loc) · 939 Bytes
/
action.go
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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Package actions contains the application logic that handles azd CLI commands.
package actions
import (
"context"
)
// ActionFunc is an Action implementation for regular functions.
type ActionFunc func(context.Context) (*ActionResult, error)
// Run implements the Action interface
func (a ActionFunc) Run(ctx context.Context) (*ActionResult, error) {
return a(ctx)
}
// Define a message as the completion of an Action.
type ResultMessage struct {
Header string
FollowUp string
}
// Define the Action outputs.
type ActionResult struct {
Message *ResultMessage
}
// Action is the representation of the application logic of a CLI command.
type Action interface {
// Run executes the CLI command.
//
// It is currently valid to both return an error and a non-nil ActionResult.
Run(ctx context.Context) (*ActionResult, error)
}