cmd

package
v0.0.0-...-b12587e Latest Latest
Warning

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

Go to latest
Published: May 7, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AddCmd = &cobra.Command{
	Use:   "add",
	Short: "Add a file to the overlay",

	Run: func(cmd *cobra.Command, args []string) {

	},
}

AddCmd represents the from command

View Source
var ApplyCmd = &cobra.Command{
	Use:   "apply",
	Short: "Apply an overlay",
	Long:  `Apply an overlay to a target directory`,
	Args:  cobra.ExactArgs(2),
	RunE: func(cmd *cobra.Command, args []string) error {
		name, target := args[0], args[1]
		cfg, err := Parse()
		if err != nil {
			return err
		}
		msg := styles.White.Sprintf("Applying overlay %s", styles.WhiteItalic.Sprint(name))
		fmt.Printf("\U0001f4e6 %s\n", msg)

		repo := over.NewRepository(cfg)
		overlay := repo.Get(name)
		if overlay == nil {
			return fmt.Errorf("Unable to find overlay '%s'", name)
		}
		err = overlay.Apply(target)
		if err != nil {
			return fmt.Errorf("Unable to apply overlay %s to %s:\n%w", overlay.Name, target, err)
		}
		fmt.Println(
			gmoji.Check,
			styles.White.Sprint("Overlay"),
			styles.WhiteItalic.Sprint(name),
			styles.White.Sprint("applied with success"),
		)
		return nil
	},
}

ApplyCmd represents the from command

View Source
var ListCmd = &cobra.Command{
	Use:     "list",
	Short:   "List known projects",
	Long:    `List all known projects`,
	Aliases: []string{"ls"},
	RunE: func(cmd *cobra.Command, args []string) error {

		cfg, err := Parse()
		if err != nil {
			return err
		}

		repo := over.NewRepository(cfg)
		for _, overlay := range repo.List() {
			fmt.Println(overlay)
			err := overlay.ParseConfig()
			if err != nil {
				return fmt.Errorf("unable to load overlay %s:\n%w", overlay, err)
			}
		}

		return nil
	},
}

ListCmd represents the from command

View Source
var NewCmd = &cobra.Command{
	Use:   "new",
	Short: "Create a new overlay",

	Run: func(cmd *cobra.Command, args []string) {

	},
}

NewCmd represents the new command

View Source
var ReleaseCmd = &cobra.Command{
	Use:   "release",
	Short: "Release a file from the overlay",
	Long:  `Release will remove a file from the overlay, and inline its content if the overlay is applied somewhere`,
	Run: func(cmd *cobra.Command, args []string) {

	},
}

ReleaseCmd represents the from command

View Source
var StatusCmd = &cobra.Command{
	Use:   "status",
	Short: "Get the current repository/directory overlays status",

	RunE: func(cmd *cobra.Command, args []string) error {
		cfg, err := Parse()
		if err != nil {
			return fmt.Errorf("unable to parse configuration: %w", err)
		}

		repo := over.NewRepository(cfg)
		fmt.Printf("Repository: %s\n", repo.Root)
		return nil
	},
}

StatusCmd represents the from command

Functions

func InitConfig

func InitConfig()

func Parse

func Parse() (*over.Config, error)

NewParser instanciate a new Viper config parser configured for over

func RootCommand

func RootCommand(name string) *cobra.Command

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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