Skip to content
go-libfossil Artifact [4acffbcbc4]
Login

Artifact [4acffbcbc4]

Artifact 4acffbcbc4c2b9f23b816c72b2ee0c528ff12ed8a7c3f4cc2ff7be2100c4830e:


package cli

import (
	"fmt"

	libfossil "github.com/danmestas/libfossil"
)

// RepoNewCmd creates a new Fossil repository.
type RepoNewCmd struct {
	Path string `arg:"" help:"Path for new repository file"`
	User string `help:"Default user name" default:""`
}

func (c *RepoNewCmd) Run(g *Globals) error {
	user := c.User
	if user == "" {
		user = currentUser()
	}
	r, err := libfossil.Create(c.Path, libfossil.CreateOpts{User: user})
	if err != nil {
		return err
	}
	r.Close()
	fmt.Printf("created repository: %s\n", c.Path)
	return nil
}