Ejemplo n.º 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")
			Ω(fc.IsSet("s")).To(BeFalse())
			Ω(fc.String("s")).To(Equal(""))

			fc.NewStringFlag("s", "s2", "setting new string flag")
			fc.Parse("-s", "test2")
			Ω(fc.IsSet("s")).To(BeTrue())
			Ω(fc.IsSet("s2")).To(BeTrue())
			Ω(fc.String("s")).To(Equal("test2"))
			Ω(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")
			Ω(fc.IsSet("s")).To(BeFalse())
			Ω(fc.String("s")).To(Equal(""))

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