cmd

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2018 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RootCmd = &cobra.Command{
	Use:   "hitree",
	Short: "Print tree structure of the directory",
	Long: `Golang implementation of popular tree command from linux.
Note: windows 10 has issue with ansi color, so for this release color output will be
disabled on windows platform.
	`,
	PersistentPreRun: func(cmd *cobra.Command, args []string) {
		nocolor := (viper.GetBool("nocolor") || (runtime.GOOS == "windows"))
		tree.InitAurora(!nocolor)
		initOptions()
		setColorOption(cmd, &opt.DirColor, "dircolor")
		setColorOption(cmd, &opt.FileColor, "filecolor")
		setColorOption(cmd, &opt.SymLinkColor, "symlinkcolor")
		setColorOption(cmd, &opt.PipeColor, "pipecolor")
		setColorOption(cmd, &opt.TLinkColor, "tlinkcolor")
		setColorOption(cmd, &opt.LLinkColor, "llinkcolor")
	},
	RunE: func(cmd *cobra.Command, args []string) error {
		showVersion, _ := cmd.Flags().GetBool("version")
		if showVersion {
			release.Print()
			return nil
		}
		path := "."
		if len(args) >= 1 {
			path = args[0]
		}

		root, err := tree.TraverseDir(path, opt, 0)
		if err != nil {
			return err
		}
		return sendOutput(cmd, root)
	},
}

RootCmd represents the base command when called without any subcommands

Functions

func Execute

func Execute(version, commit, date interface{})

Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

Types

This section is empty.

Jump to

Keyboard shortcuts

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