示例#1
0
			opt, err := parser.ParseArgs(&[]string{"--is-provided", "foo"})
			Expect(err).To(BeNil())

			// All options required have values
			Expect(opt.Required([]string{"is-set", "is-provided"})).To(BeNil())

			// Option 'not-set' is missing is not provided
			err = opt.Required([]string{"is-set", "is-provided", "not-set"})
			Expect(err).To(Not(BeNil()))
			Expect(err.Error()).To(Equal("not-set"))
		})
	})

	Describe("ToString()", func() {
		It("Should return a string representation of the options", func() {
			output := opts.ToString()
			Expect(output).To(Equal(`{
  'bool' = true
  'deeply' = {
    'foo' = bar
    'nested' = {
      'thing' = foo
    }
  }
  'endpoints' = {
    'endpoint1' = host1
    'endpoint2' = host2
    'endpoint3' = host3
  }
  'int' = 1
  'string' = one