func parseArguments(args []string) (flags.FlagContext, error) { fc := flags.New() fc.NewBoolFlag("started", "s", "Shows only apps that are started") fc.NewBoolFlag("stopped", "o", "Shows only apps that are stopped") err := fc.Parse(args...) return fc, err }
package flags_test import ( "code.cloudfoundry.org/cli/cf/flags" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("Flag Constructors", func() { var ( fc flags.FlagContext ) BeforeEach(func() { fc = flags.New() }) Describe("NewStringFlag()", func() { It("init the flag context with a new string flagset", func() { fc.Parse("-s", "test") Expect(fc.IsSet("s")).To(BeFalse()) Expect(fc.String("s")).To(Equal("")) fc.NewStringFlag("s", "s2", "setting new string flag") fc.Parse("-s", "test2") Expect(fc.IsSet("s")).To(BeTrue()) Expect(fc.IsSet("s2")).To(BeTrue()) Expect(fc.String("s")).To(Equal("test2")) Expect(fc.String("s2")).To(Equal("test2")) })