func helpText(command cmd.Command, name string) string { buff := &bytes.Buffer{} info := command.Info() info.Name = name f := gnuflag.NewFlagSet(info.Name, gnuflag.ContinueOnError) command.SetFlags(f) buff.Write(info.Help(f)) return buff.String() }
func (r *stubRegistry) RegisterDeprecated(subcmd cmd.Command, check cmd.DeprecationCheck) { r.stub.AddCall("RegisterDeprecated", subcmd, check) r.stub.NextErr() // pop one off r.names = append(r.names, subcmd.Info().Name) for _, name := range subcmd.Info().Aliases { r.names = append(r.names, name) } }
func (r *stubRegistry) Register(subcmd cmd.Command) { r.stub.AddCall("Register", subcmd) r.stub.NextErr() // pop one off r.names = append(r.names, subcmd.Info().Name) for _, name := range subcmd.Info().Aliases { r.names = append(r.names, name) } }
func (s *BaseActionSuite) checkHelp(c *gc.C, subcmd cmd.Command) { ctx, err := coretesting.RunCommand(c, s.command, subcmd.Info().Name, "--help") c.Assert(err, gc.IsNil) expected := "(?sm).*^usage: juju action " + regexp.QuoteMeta(subcmd.Info().Name) + ` \[options\] ` + regexp.QuoteMeta(subcmd.Info().Args) + ".+" c.Check(coretesting.Stdout(ctx), gc.Matches, expected) expected = "(?sm).*^purpose: " + regexp.QuoteMeta(subcmd.Info().Purpose) + "$.*" c.Check(coretesting.Stdout(ctx), gc.Matches, expected) expected = "(?sm).*^" + regexp.QuoteMeta(subcmd.Info().Doc) + "$.*" c.Check(coretesting.Stdout(ctx), gc.Matches, expected) }
func (s *BaseBackupsSuite) checkHelp(c *gc.C, subcmd cmd.Command) { ctx, err := jujutesting.RunCommand(c, s.command, subcmd.Info().Name, "--help") c.Assert(err, gc.IsNil) var expected string if subcmd.Info().Args != "" { expected = "(?sm).*^Usage: juju backups " + regexp.QuoteMeta(subcmd.Info().Name) + ` \[options\] ` + regexp.QuoteMeta(subcmd.Info().Args) + ".+" } else { expected = "(?sm).*^Usage: juju backups " + regexp.QuoteMeta(subcmd.Info().Name) + ` \[options\].+` } c.Check(jujutesting.Stdout(ctx), gc.Matches, expected) expected = "(?sm).*^Summary:\n" + regexp.QuoteMeta(subcmd.Info().Purpose) + "$.*" c.Check(jujutesting.Stdout(ctx), gc.Matches, expected) expected = "(?sm).*^Details:" + regexp.QuoteMeta(subcmd.Info().Doc) + "$.*" c.Check(jujutesting.Stdout(ctx), gc.Matches, expected) }
func (m *mockRegister) Register(command cmd.Command) { m.commands = append(m.commands, command.Info().Name) }