Example #1
0
	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"))
		})
	})

	Describe("NewStringFlagWithDefault()", func() {
		It("init the flag context with a new string flagset with default value", func() {
			fc.Parse("-s", "test")
			Expect(fc.IsSet("s")).To(BeFalse())
			Expect(fc.String("s")).To(Equal(""))

			fc.NewStringFlagWithDefault("s", "s2", "setting new string flag", "barz")