cmd

package
v0.0.0-...-bb263ce Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 9, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RootCmd = &cobra.Command{
	Use:   "pasta",
	Short: "pasta - copy files between repositories",
	Run: func(cmd *cobra.Command, args []string) {
		if versionFlag {
			v := version
			if v == "" {
				v = "<unknown version>"
			}

			fmt.Println(v)

			os.Exit(0)
		}

		pathToYaml, err := findPastaFile()

		if err != nil {
			fmt.Fprintf(os.Stderr, "Error trying to find pasta file: %v\n", err)
			os.Exit(-1)
		}

		cfg, err := newPastaConf(pathToYaml)
		if err != nil {
			fmt.Fprintf(os.Stderr, "Error while parsing config: %v\n", err)
			os.Exit(-2)
		}

		if len(cfg.Deps) == 0 {
			fmt.Printf("No dependencies found in '%s'\n", pathToYaml)
			return
		}

		if dryRunFlag {
			fmt.Println("--dry-run is set, here's what would happen:")
			fmt.Println()
		}

		ctx := context.Background()
		err = pasta.Run(ctx, cfg.dependencies, dryRunFlag, cfg.KeepDirs, pathToYaml)

		if err != nil {
			fmt.Fprintf(os.Stderr, "Error while running pasta: %v\n", err)
			os.Exit(-4)
		}
	},
}

Functions

func Execute

func Execute()

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL