Skip to content
go-libfossil Artifact [3696eb11ee]
Login

Artifact [3696eb11ee]

Artifact 3696eb11eeedaf6426383c92f35962bbcf442ece0a9588f50155b35399afb5df:


package cli

import (
	"fmt"

	libfossil "github.com/danmestas/go-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
}