Skip to content

Commit

Permalink
#24
Browse files Browse the repository at this point in the history
  • Loading branch information
ufasoli committed Jul 27, 2020
1 parent 9549b0e commit 8af717c
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ var rootCmd = &cobra.Command{
Long: `Platys modern data platform generator
Complete documentation is available at https://github.com/TrivadisPF/platys`,
Run: func(cmd *cobra.Command, args []string) {
// Do Stuff Here
if len(args) == 0 { // no argument provided invoke help command
cmd.Help()
os.Exit(0)
}
},
}

Expand All @@ -39,18 +42,14 @@ func init() {
rootCmd.PersistentFlags().BoolVarP(&Verbose, "verbose", "v", true, "verbose output")
}

func er(msg interface{}) {
fmt.Println("Error:", msg)
os.Exit(1)
}

func Execute() {
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}

// extracts the config.yml file from the docker image
func pullConfig() string {

cli, ctx := initClient()
Expand Down Expand Up @@ -109,6 +108,8 @@ func pullConfig() string {
return config_file
}

// extracts the provided file/folder from the docker image
// file/folders are returned as a tar file
func getFile(filePath string) (io.ReadCloser, types.ContainerPathStat, error) {

cli, ctx := initClient()
Expand Down Expand Up @@ -146,6 +147,7 @@ func getFile(filePath string) (io.ReadCloser, types.ContainerPathStat, error) {
return cli.CopyFromContainer(ctx, resp.ID, filePath)
}

// stops and removes the provided container id
func stopRemoveContainer(id string, cli *client.Client, ctx context.Context) {

err := cli.ContainerStop(context.Background(), id, nil)
Expand All @@ -162,6 +164,7 @@ func stopRemoveContainer(id string, cli *client.Client, ctx context.Context) {
}
}

// boilerplate code to init the docker cli
func initClient() (*client.Client, context.Context) {
ctx := context.Background()

Expand All @@ -179,9 +182,9 @@ func initClient() (*client.Client, context.Context) {
return cli, ctx
}

// prints the help banner
func printBanner() {


f, err := pkger.Open("/assets/init_banner.txt")
if err != nil {
panic(err)
Expand Down

0 comments on commit 8af717c

Please sign in to comment.