Exemplo n.º 1
0
					Expect(fCtx.IsSet("noDefaultStringFlag")).To(BeTrue())
				})

				It("appends argument value to StringSliceFlag to the default values", func() {
					err := fCtx.Parse("-defaultStringAryFlag=foo", "-defaultStringAryFlag=bar")
					Expect(err).NotTo(HaveOccurred())

					Expect(fCtx.StringSlice("defaultStringAryFlag")).To(Equal([]string{"abc", "def", "foo", "bar"}))
					Expect(fCtx.IsSet("defaultStringAryFlag")).To(BeTrue())
				})

			})

			Context("SkipFlagParsing", func() {
				It("skips flag parsing and treats all arguments as values", func() {
					fCtx.SkipFlagParsing(true)
					err := fCtx.Parse("value1", "--name", "foo")
					Expect(err).NotTo(HaveOccurred())

					Expect(fCtx.IsSet("name")).To(Equal(false))

					Expect(len(fCtx.Args())).To(Equal(3))
					Expect(fCtx.Args()[0]).To(Equal("value1"))
					Expect(fCtx.Args()[1]).To(Equal("--name"))
					Expect(fCtx.Args()[2]).To(Equal("foo"))
				})
			})

		})

	})