add filters for courses
This commit is contained in:
@ -13,22 +13,24 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
learningTypeOptName = "learning-type"
|
||||
courseThematicOptName = "course-thematic"
|
||||
learningTypeOptName = "learning-type"
|
||||
courseThematicOptName = "course-thematic"
|
||||
learningTypeSelectionOptName = "learning-selection"
|
||||
)
|
||||
|
||||
func setupAPICommand(ctx context.Context) cli.Command {
|
||||
learningTypeOpt := cli.NewOption(learningTypeOptName, "Specify learning type").
|
||||
WithChar('l').
|
||||
WithType(cli.TypeString)
|
||||
courseThematic := cli.NewOption(courseThematicOptName, "Specify course thematic").
|
||||
WithChar('t').
|
||||
WithType(cli.TypeString)
|
||||
learningSelectionOpt := cli.NewOption(learningTypeSelectionOptName, "Specify learning type selection").
|
||||
WithType(cli.TypeString)
|
||||
|
||||
apiEducationListProducts := buildCLICommand(func() cli.Command {
|
||||
return cli.NewCommand("list_products", "List products by some filters").
|
||||
WithOption(learningTypeOpt).
|
||||
WithOption(courseThematic).
|
||||
WithOption(learningSelectionOpt).
|
||||
WithOption(limitOption).
|
||||
WithOption(offsetOption).
|
||||
WithAction(newListProductAction(ctx))
|
||||
@ -67,10 +69,11 @@ func asCLIAction(a action) cli.Action {
|
||||
}
|
||||
|
||||
type listProductsActionParams struct {
|
||||
learningType string
|
||||
courseThematic string
|
||||
limit int
|
||||
offset int
|
||||
learningType string
|
||||
courseThematic string
|
||||
learningSelectionType string
|
||||
limit int
|
||||
offset int
|
||||
}
|
||||
|
||||
type listProductsAction struct {
|
||||
@ -102,6 +105,7 @@ func (a *listProductsAction) parse(args []string, options map[string]string) err
|
||||
}
|
||||
|
||||
a.params.courseThematic = options[courseThematicOptName]
|
||||
a.params.learningSelectionType = options[learningTypeSelectionOptName]
|
||||
|
||||
if value, ok := options[limitOption.Key()]; ok {
|
||||
a.params.limit, _ = strconv.Atoi(value)
|
||||
|
||||
Reference in New Issue
Block a user