Skip to content

Commit ef19aaa

Browse files
committed
Scratch that, use it even more.
1 parent 48e91a7 commit ef19aaa

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

pkg/stats/historical.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"sort"
88

99
"github.com/fastly/cli/pkg/common"
10+
"github.com/fastly/cli/pkg/compute/manifest"
1011
"github.com/fastly/cli/pkg/config"
1112
"github.com/fastly/go-fastly/fastly"
1213
)
@@ -16,6 +17,7 @@ const statusSuccess = "success"
1617
// HistoricalCommand exposes the Historical Stats API.
1718
type HistoricalCommand struct {
1819
common.Base
20+
manifest manifest.Data
1921

2022
Input fastly.GetStatsInput
2123
formatFlag string
@@ -27,7 +29,7 @@ func NewHistoricalCommand(parent common.Registerer, globals *config.Data) *Histo
2729
c.Globals = globals
2830

2931
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)
3133

3234
c.CmdClause.Flag("from", "From time, accepted formats at https://docs.fastly.com/api/stats#Range").StringVar(&c.Input.From)
3335
c.CmdClause.Flag("to", "To time").StringVar(&c.Input.To)
@@ -41,6 +43,11 @@ func NewHistoricalCommand(parent common.Registerer, globals *config.Data) *Histo
4143

4244
// Exec implements the command interface.
4345
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+
4451
var envelope statsResponse
4552
err := c.Globals.Client.GetStatsJSON(&c.Input, &envelope)
4653
if err != nil {

0 commit comments

Comments
 (0)