package command import ( "context" "gitoa.ru/go-4devs/console" "gitoa.ru/go-4devs/console/input" "gitoa.ru/go-4devs/console/input/option" "gitoa.ru/go-4devs/console/output" ) func Args() *console.Command { return &console.Command{ Name: "fdevs:console:arg", Description: "Understanding how Console Arguments and Options Are Handled", Configure: func(ctx context.Context, def *input.Definition) error { def.SetOptions( option.Bool("foo", "foo option", option.Short("f")), option.New("bar", "required bar option", option.Required, option.Short("b")), option.New("cat", "cat option", option.Short("c")), ) return nil }, Execute: func(ctx context.Context, in input.Input, out output.Output) error { out.Println(ctx, "foo: ", in.Option(ctx, "foo").Bool(), "") out.Println(ctx, "bar: ", in.Option(ctx, "bar").String(), "") out.Println(ctx, "cat: ", in.Option(ctx, "cat").String(), "") return nil }, } }