commands/migrate: declare info subcommand in main init()

This commit is contained in:
Taylor Blau 2017-06-12 15:22:49 -06:00
parent 1b0d830e45
commit 1f443d0818
2 changed files with 4 additions and 7 deletions

@ -206,6 +206,9 @@ func getHistoryRewriter(cmd *cobra.Command, db *odb.ObjectDatabase) *githistory.
}
func init() {
info := NewCommand("info", migrateInfoCommand)
info.Flags().IntVar(&migrateInfoTopN, "top", 5, "--top=<n>")
RegisterCommand("migrate", nil, func(cmd *cobra.Command) {
// Adding flags directly to cmd.Flags() doesn't apply those
// flags to any subcommands of the root. Therefore, loop through
@ -216,7 +219,7 @@ func init() {
// `git-lfs-migrate(1)` command as a subcommand (child).
for _, subcommand := range []*cobra.Command{
MigrateInfoCommand,
info,
} {
subcommand.Flags().StringVarP(&includeArg, "include", "I", "", "Include a list of paths")
subcommand.Flags().StringVarP(&excludeArg, "exclude", "X", "", "Exclude a list of paths")

@ -13,8 +13,6 @@ import (
"github.com/spf13/cobra"
)
var MigrateInfoCommand = NewCommand("info", migrateInfoCommand)
var (
// migrateInfoTopN is a flag given to the git-lfs-migrate(1) subcommand
// 'info' which specifies how many info entries to show by default.
@ -111,7 +109,3 @@ func (e EntriesBySize) Print(to io.Writer) (int, error) {
return fmt.Fprintln(to, strings.Join(output, "\n"))
}
func init() {
MigrateInfoCommand.Flags().IntVar(&migrateInfoTopN, "top", 5, "--top=<n>")
}