Ejemplo n.º 1
0
			Expect(opt.Int("power-level")).To(Equal(1))
			Expect(opt.NoArgs()).To(Equal(true))
		})
		It("Should return false if arguments on the command line", func() {
			parser := args.NewParser()
			parser.AddOption("--power-level").IsInt().Default("1")

			opt, err := parser.ParseArgs(&[]string{"--power-level", "2"})
			Expect(err).To(BeNil())
			Expect(opt.Int("power-level")).To(Equal(2))
			Expect(opt.NoArgs()).To(Equal(false))
		})
	})
	Describe("ToMap()", func() {
		It("Should return a map of the group options", func() {
			Expect(opts.Group("endpoints").ToMap()).To(Equal(map[string]interface{}{
				"endpoint1": "host1",
				"endpoint2": "host2",
				"endpoint3": "host3",
			}))
		})
		It("Should return an empty map if the group doesn't exist", func() {
			Expect(opts.Group("no-group").ToMap()).To(Equal(map[string]interface{}{}))
		})
	})

	Describe("IsSet()", func() {
		It("Should return true if the value is not a cast default", func() {
			parser := args.NewParser()
			parser.AddOption("--is-set").IsInt().Default("1")
			parser.AddOption("--not-set")