cmd

package
v0.0.0-...-1a2a7be Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2017 License: GPL-3.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RootCmd = &cobra.Command{
	Use:   "generate_container_impl",
	Short: "generate container_impl.go",
	Run: func(cmd *cobra.Command, args []string) {
		container_impl_file := inputDir + "/container_impl.go.template"
		container_main_file := inputDir + "/main.go.template"

		impl_buf, err := ioutil.ReadFile(container_impl_file)
		if err != nil {
			cmd.Printf("failed to open %v: %v\n", container_impl_file, err)
			return
		}

		main_buf, err := ioutil.ReadFile(container_main_file)
		if err != nil {
			cmd.Printf("failed to open %v: %v\n", container_main_file, err)
			return
		}

		output_file, err := os.Create(output)
		if err != nil {
			cmd.Printf("failed to write file %v: %v\n", output, err)
			return
		}

		impl_tmpl := template.Must(template.New("container_impl").Parse(string(impl_buf)))
		impl_tmpl.Execute(output_file, struct{ Code string }{string(main_buf)})

		cmd.Printf("Generated...\n")
	},
}

RootCmd represents the base command when called without any subcommands

Functions

func Execute

func Execute()

Execute adds all child commands to the root command 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