Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkg/cmd/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var (
// PaginationDirection is a list of directions the page results can be displayed.
var PaginationDirection = []string{"ascend", "descend"}

// CursorFlag returns a cursor flag definition.
func CursorFlag(dst *string) StringFlagOpts {
return StringFlagOpts{
Name: "cursor",
Expand All @@ -35,6 +36,7 @@ func CursorFlag(dst *string) StringFlagOpts {
}
}

// LimitFlag returns a limit flag definition.
func LimitFlag(dst *int) IntFlagOpts {
return IntFlagOpts{
Name: "limit",
Expand All @@ -45,6 +47,7 @@ func LimitFlag(dst *int) IntFlagOpts {
}
}

// StoreIDFlag returns a store-id flag definition.
func StoreIDFlag(dst *string) StringFlagOpts {
return StringFlagOpts{
Name: "store-id",
Expand Down
4 changes: 3 additions & 1 deletion pkg/fmt/fmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ import (
"github.com/fastly/cli/pkg/text"
)

// Success is a test helper used to generate output for asserting against.
func Success(format string, args ...any) string {
var b bytes.Buffer
text.Success(&b, format, args...)
return b.String()
}

// JSON decodes then re-encodes back to JSON, with indentation matching
// that of jsonOutput.WriteJSON.
// that of ../cmd/cmd.go's cmd.WriteJSON.
func JSON(format string, args ...any) string {
var r json.RawMessage
if err := json.Unmarshal([]byte(fmt.Sprintf(format, args...)), &r); err != nil {
Expand All @@ -24,6 +25,7 @@ func JSON(format string, args ...any) string {
return EncodeJSON(r)
}

// EncodeJSON is a test helper that encodes any Go type into JSON.
func EncodeJSON(value any) string {
var b bytes.Buffer
enc := json.NewEncoder(&b)
Expand Down