7
7
"sort"
8
8
9
9
"github.com/fastly/cli/pkg/common"
10
+ "github.com/fastly/cli/pkg/compute/manifest"
10
11
"github.com/fastly/cli/pkg/config"
11
12
"github.com/fastly/go-fastly/fastly"
12
13
)
@@ -16,6 +17,7 @@ const statusSuccess = "success"
16
17
// HistoricalCommand exposes the Historical Stats API.
17
18
type HistoricalCommand struct {
18
19
common.Base
20
+ manifest manifest.Data
19
21
20
22
Input fastly.GetStatsInput
21
23
formatFlag string
@@ -27,7 +29,7 @@ func NewHistoricalCommand(parent common.Registerer, globals *config.Data) *Histo
27
29
c .Globals = globals
28
30
29
31
c .CmdClause = parent .Command ("historical" , "View historical stats for a Fastly service" )
30
- c .CmdClause .Flag ("service-id" , "Service ID" ).Short ('s' ).StringVar (& c .Input . Service )
32
+ c .CmdClause .Flag ("service-id" , "Service ID" ).Short ('s' ).StringVar (& c .manifest . Flag . ServiceID )
31
33
32
34
c .CmdClause .Flag ("from" , "From time, accepted formats at https://docs.fastly.com/api/stats#Range" ).StringVar (& c .Input .From )
33
35
c .CmdClause .Flag ("to" , "To time" ).StringVar (& c .Input .To )
@@ -41,6 +43,11 @@ func NewHistoricalCommand(parent common.Registerer, globals *config.Data) *Histo
41
43
42
44
// Exec implements the command interface.
43
45
func (c * HistoricalCommand ) Exec (in io.Reader , out io.Writer ) error {
46
+ service , source := c .manifest .ServiceID ()
47
+ if source != manifest .SourceUndefined {
48
+ c .Input .Service = service
49
+ }
50
+
44
51
var envelope statsResponse
45
52
err := c .Globals .Client .GetStatsJSON (& c .Input , & envelope )
46
53
if err != nil {
0 commit comments