Exemplo n.º 1
0
func init() {
	states := make([]string, 0, len(stateEnum))
	for _, state := range stateEnum {
		states = append(states, string(state))
	}

	// Finalize Command.
	Command.UsageLine = fmt.Sprintf("prune [-state={%v}]", strings.Join(states, "|"))

	// Register flags.
	flagState = flag.NewStringEnumFlag(states, string(common.StoryStateAccepted))
	Command.Flags.Var(flagState, "state", "set the required story state for branch removal")

	// Register global flags.
	appflags.RegisterGlobalFlags(&Command.Flags)
}
Exemplo n.º 2
0
import (
	// Stdlib
	"errors"
	"flag"

	// Internal
	"github.com/salsaflow/salsaflow/errs"
	flags "github.com/salsaflow/salsaflow/flag"
	"github.com/salsaflow/salsaflow/log"
	"github.com/salsaflow/salsaflow/repo"
)

var ErrRepositoryNotInitialised = errors.New("repository not initialised")

var (
	LogFlag *flags.StringEnumFlag = flags.NewStringEnumFlag(
		log.LevelStrings(), log.MustLevelToString(log.Info))
)

func RegisterGlobalFlags(flags *flag.FlagSet) {
	flags.Var(LogFlag, "log", "set logging verbosity; {trace|debug|verbose|info|off}")
}

func Init(force bool) error {
	// Set up logging.
	log.SetV(log.MustStringToLevel(LogFlag.Value()))

	// Make sure the repo is initialised.
	if err := repo.Init(force); err != nil {
		return err
	}
Exemplo n.º 3
0
	"gopkg.in/tchap/gocli.v2"
)

var Command = &gocli.Command{
	UsageLine: "notes [-format=FORMAT] [-pretty] VERSION",
	Short:     "print release notes",
	Long: fmt.Sprintf(`
  Print release notes for release VERSION.

  Supported formats: %v
	`, strings.Join(notes.AvailableEncodings(), ", ")),
	Action: run,
}

var (
	flagFormat = flag.NewStringEnumFlag(notes.AvailableEncodings(), string(notes.EncodingJson))
	flagPretty bool
)

func init() {
	// Register flags.
	Command.Flags.Var(flagFormat, "format", "output format")
	Command.Flags.BoolVar(&flagPretty, "pretty", flagPretty, "pretty-print the output")

	// Register global flags.
	appflags.RegisterGlobalFlags(&Command.Flags)
}

func run(cmd *gocli.Command, args []string) {
	if len(args) != 1 {
		cmd.Usage()