github.com/taubyte/tau-cli@v0.1.13-0.20240326000942-487f0d57edfc/cli/commands/dream/command.go (about)

     1  package dream
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/taubyte/tau-cli/cli/commands/dream/build"
     7  	dreamLib "github.com/taubyte/tau-cli/lib/dream"
     8  	projectLib "github.com/taubyte/tau-cli/lib/project"
     9  	"github.com/urfave/cli/v2"
    10  )
    11  
    12  const (
    13  	defaultBind        = "node@1/verbose,seer@2/copies,node@2/copies"
    14  	dreamCacheLocation = "~/.cache/dreamland/universe-tau"
    15  )
    16  
    17  var (
    18  	cacheDream = []string{"--id", "tau", "--keep"}
    19  )
    20  
    21  var Command = &cli.Command{
    22  	Name:  "dream",
    23  	Usage: "Starts and interfaces with a local taubyte network.  All leading arguments to `tau dream ...` are passed to dreamland",
    24  	Flags: []cli.Flag{
    25  		&cli.BoolFlag{
    26  			Name:  "cache",
    27  			Usage: fmt.Sprintf("caches the universe in `%s` keeping data for subsequent restarts", dreamCacheLocation),
    28  		},
    29  	},
    30  	Action: func(c *cli.Context) error {
    31  		project, err := projectLib.SelectedProjectInterface()
    32  		if err != nil {
    33  			return err
    34  		}
    35  
    36  		h := projectLib.Repository(project.Get().Name())
    37  		projectRepositories, err := h.Open()
    38  		if err != nil {
    39  			return err
    40  		}
    41  
    42  		branch, err := projectRepositories.CurrentBranch()
    43  		if err != nil {
    44  			return err
    45  		}
    46  
    47  		baseStartDream := []string{"new", "multiverse", "--bind", defaultBind, "--branch", branch}
    48  		if c.IsSet("cache") {
    49  			return dreamLib.Execute(append(baseStartDream, cacheDream...)...)
    50  		} else {
    51  			return dreamLib.Execute(baseStartDream...)
    52  		}
    53  	},
    54  
    55  	Subcommands: []*cli.Command{
    56  		injectCommand,
    57  		attachCommand,
    58  		build.Command,
    59  	},
    60  }