diff --git a/cmd/list.go b/cmd/list.go index 6a9c3dd..1deac94 100644 --- a/cmd/list.go +++ b/cmd/list.go @@ -69,7 +69,7 @@ func NewCmdList() *cobra.Command { listCmd.Flags().StringVarP(&f.Repo, "repo", "R", "", "Select another repository for finding actions cache.") listCmd.Flags().StringVarP(&f.Branch, "branch", "B", "", "Filter by branch") - listCmd.Flags().IntVarP(&f.Limit, "limit", "", 30, "Number of items to fetch between 1 and 100") + listCmd.Flags().IntVarP(&f.Limit, "limit", "L", 30, "Number of items to fetch between 1 and 100") listCmd.Flags().StringVarP(&f.Key, "key", "", "", "Filter by key") listCmd.Flags().StringVarP(&f.Order, "order", "", "", "Order of caches returned (asc/desc)") listCmd.Flags().StringVarP(&f.Sort, "sort", "", "", "Sort fetched caches (last-used/size/created-at)") diff --git a/cmd/list_test.go b/cmd/list_test.go index 419425f..f8429dc 100644 --- a/cmd/list_test.go +++ b/cmd/list_test.go @@ -62,6 +62,18 @@ func TestListWithIncorrectLimit(t *testing.T) { assert.True(t, gock.IsDone(), internal.PrintPendingMocks(gock.Pending())) } +func TestListLimitShorthandUsingIncorrectLimit(t *testing.T) { + t.Cleanup(gock.Off) + + cmd := NewCmdList() + cmd.SetArgs([]string{"-L", "102", "--repo", "testOrg/testRepo"}) + err := cmd.Execute() + + assert.NotNil(t, err) + assert.Equal(t, err, fmt.Errorf("102 is not a valid integer value for limit flag. Allowed values: 1-100")) + assert.True(t, gock.IsDone(), internal.PrintPendingMocks(gock.Pending())) +} + func TestListWithIncorrectOrder(t *testing.T) { t.Cleanup(gock.Off)