func newLogWithFlags(c *gc.C, flags []string) *cmd.Log { log := &cmd.Log{} flagSet := coretesting.NewFlagSet() log.AddFlags(flagSet) err := flagSet.Parse(false, flags) c.Assert(err, gc.IsNil) return log }
func (s *CmdSuite) TestInfo(c *gc.C) { minimal := &TestCommand{Name: "verb", Minimal: true} help := minimal.Info().Help(testing.NewFlagSet()) c.Assert(string(help), gc.Equals, minimalHelp) full := &TestCommand{Name: "verb"} f := testing.NewFlagSet() var ignored string f.StringVar(&ignored, "option", "", "option-doc") help = full.Info().Help(f) c.Assert(string(help), gc.Equals, fullHelp) optionInfo := full.Info() optionInfo.Doc = "" help = optionInfo.Help(f) c.Assert(string(help), gc.Equals, optionHelp) }
func (s *OpenedPortsSuite) TestHelp(c *gc.C) { hctx := s.GetHookContext(c, -1, "") openedPorts, err := jujuc.NewCommand(hctx, cmdString("opened-ports")) c.Assert(err, jc.ErrorIsNil) flags := testing.NewFlagSet() c.Assert(string(openedPorts.Info().Help(flags)), gc.Equals, ` usage: opened-ports purpose: lists all ports or ranges opened by the unit Each list entry has format <port>/<protocol> (e.g. "80/tcp") or <from>-<to>/<protocol> (e.g. "8080-8088/udp"). `[1:]) }
func (s *PortsSuite) TestHelp(c *gc.C) { hctx := s.GetHookContext(c, -1, "") open, err := jujuc.NewCommand(hctx, cmdString("open-port")) c.Assert(err, jc.ErrorIsNil) flags := testing.NewFlagSet() c.Assert(string(open.Info().Help(flags)), gc.Equals, ` usage: open-port <port>[/<protocol>] or <from>-<to>[/<protocol>] purpose: register a port or range to open The port range will only be open while the service is exposed. `[1:]) close, err := jujuc.NewCommand(hctx, cmdString("close-port")) c.Assert(err, jc.ErrorIsNil) c.Assert(string(close.Info().Help(flags)), gc.Equals, ` usage: close-port <port>[/<protocol>] or <from>-<to>[/<protocol>] purpose: ensure a port or range is always closed `[1:]) }
func fs() (*gnuflag.FlagSet, *cmd.FileVar) { var config cmd.FileVar fs := testing.NewFlagSet() fs.Var(&config, "config", "the config") return fs, &config }