コード例 #1
0
ファイル: flags_usage_test.go プロジェクト: Doebe/workplace
var _ = Describe("Showing Flags Usage", func() {

	var (
		fc flags.FlagContext
	)

	BeforeEach(func() {
		fc = flags.New()
		fc.NewIntFlag("intFlag", "i", "Usage for intFlag")
		fc.NewIntFlag("m", "", "Usage for intFlag")
		fc.NewBoolFlag("boolFlag", "b", "Usage for boolFlag")
		fc.NewBoolFlag("f", "", "Usage for f")
	})

	It("prints both the full and short flag name", func() {
		outputs := fc.ShowUsage(0)
		Ω(outputs).To(ContainSubstring("-intFlag, -i"))
		Ω(outputs).To(ContainSubstring("-f"))
		Ω(outputs).To(ContainSubstring("--boolFlag, -b"))
	})

	It("prints full flag name with double dashes (--) if shortName exists", func() {
		outputs := fc.ShowUsage(1)
		Ω(outputs).To(ContainSubstring(" --intFlag"))
		Ω(outputs).To(ContainSubstring(" -m"))
		Ω(outputs).To(ContainSubstring(" -f"))
		Ω(outputs).To(ContainSubstring(" --boolFlag, -b"))
	})

	It("prefixes the flag name with spaces", func() {
		outputs := fc.ShowUsage(5)