internal/dis: Add 'watcher' component for infos
This commit is contained in:
parent
162b1d3d65
commit
8cfb23bed0
8 changed files with 132 additions and 33 deletions
|
|
@ -24,7 +24,7 @@ func (info) Description() wisski_distillery.Description {
|
|||
NeedsDistillery: true,
|
||||
},
|
||||
Command: "info",
|
||||
Description: "Provide information about a single repository",
|
||||
Description: "Provide information about a single instance",
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
48
cmd/status.go
Normal file
48
cmd/status.go
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
wisski_distillery "github.com/FAU-CDI/wisski-distillery"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/cli"
|
||||
)
|
||||
|
||||
// Info is then 'info' command
|
||||
var Status wisski_distillery.Command = cStatus{}
|
||||
|
||||
type cStatus struct {
|
||||
JSON bool `short:"j" long:"json" description:"Print status as JSON instead of as string"`
|
||||
}
|
||||
|
||||
func (cStatus) Description() wisski_distillery.Description {
|
||||
return wisski_distillery.Description{
|
||||
Requirements: cli.Requirements{
|
||||
NeedsDistillery: true,
|
||||
},
|
||||
Command: "status",
|
||||
Description: "Provide information about the distillery as a whole",
|
||||
}
|
||||
}
|
||||
|
||||
func (s cStatus) Run(context wisski_distillery.Context) error {
|
||||
status, _, err := context.Environment.Info().Status(true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if s.JSON {
|
||||
json.NewEncoder(context.Stdout).Encode(status)
|
||||
return nil
|
||||
}
|
||||
|
||||
context.Printf("Total Instances: %v\n", status.TotalCount)
|
||||
context.Printf(" (running): %v\n", status.RunningCount)
|
||||
context.Printf(" (stopped): %v\n", status.StoppedCount)
|
||||
|
||||
context.Printf("Backups: (count %d)\n", len(status.Backups))
|
||||
for _, s := range status.Backups {
|
||||
context.Printf("- %s (slug %q, taken %s, packed %v)\n", s.Path, s.Slug, s.Created.String(), s.Packed)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
@ -57,6 +57,9 @@ func init() {
|
|||
// servers
|
||||
wdcli.Register(cmd.Server)
|
||||
wdcli.Register(cmd.SSH)
|
||||
|
||||
// status
|
||||
wdcli.Register(cmd.Status)
|
||||
}
|
||||
|
||||
// an error when no arguments are provided.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue