11package cmd
22
33import (
4+ "os"
5+ "path"
6+
7+ "github.com/bcaldwell/devctl/postCommand"
8+
49 "github.com/bcaldwell/devctl/plugins"
10+ "github.com/bcaldwell/devctl/utilities"
511 "github.com/spf13/cobra"
612)
713
14+ //go:generate go-bindata -prefix "../" -o bindata.go -pkg cmd ../devctl.sh
15+
816// setupCmd represents the setup command
917var setupCmd = & cobra.Command {
1018 Use : "setup" ,
@@ -20,21 +28,24 @@ to quickly create a Cobra application.`,
2028
2129func init () {
2230 devctlCmd .AddCommand (setupCmd )
31+ }
2332
24- // Here you will define your flags and configuration settings.
33+ func setup (cmd * cobra.Command , args []string ) {
34+ data , err := Asset ("devctl.sh" )
35+ utilities .Check (err , "Fetching devctl.sh file contents" )
2536
26- // Cobra supports Persistent Flags which will work for this command
27- // and all subcommands, e.g.:
28- // setupCmd.PersistentFlags().String("foo", "", "A help for foo")
37+ fileName := path .Join (devctlHomeFolder , "devctl.sh" )
38+ utilities .Check (err , "Creating file " + fileName )
39+ f , err := os .Create (fileName )
40+ defer f .Close ()
2941
30- // Cobra supports local flags which will only run when this command
31- // is called directly, e.g.:
32- // setupCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
42+ _ , err = f .Write (data )
43+ utilities .Check (err , "Writing contents to " + fileName )
3344
34- }
45+ // TODO: source file
46+
47+ postCommand .RunCommand ("source " + fileName )
3548
36- func setup (cmd * cobra.Command , args []string ) {
37- // TODO: Work your own magic here
3849 for _ , i := range plugins .List {
3950 i .Setup ()
4051 }
0 commit comments