Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/spf13/viper"

"github.com/gomicro/forge/confile"
clifmt "github.com/gomicro/forge/fmt"
)

func init() {
Expand All @@ -18,28 +17,28 @@ func init() {
RootCmd.PersistentFlags().Bool("verbose", false, "show more verbose output")
err := viper.BindPFlag("verbose", RootCmd.PersistentFlags().Lookup("verbose"))
if err != nil {
clifmt.Printf("Error setting up: %v\n", err.Error())
fmt.Printf("Error setting up: %s\n", err)
os.Exit(1)
}

RootCmd.PersistentFlags().Bool("solo", false, "run a step solo, without its pre or post steps")
err = viper.BindPFlag("solo", RootCmd.PersistentFlags().Lookup("solo"))
if err != nil {
clifmt.Printf("Error setting up: %v\n", err.Error())
fmt.Printf("Error setting up: %s\n", err)
os.Exit(1)
}

RootCmd.PersistentFlags().Bool("no-pre", false, "skip running pre steps")
err = viper.BindPFlag("no-pre", RootCmd.PersistentFlags().Lookup("no-pre"))
if err != nil {
clifmt.Printf("Error setting up: %v\n", err.Error())
fmt.Printf("Error setting up: %s\n", err)
os.Exit(1)
}

RootCmd.PersistentFlags().Bool("no-post", false, "skip running post steps")
err = viper.BindPFlag("no-post", RootCmd.PersistentFlags().Lookup("no-post"))
if err != nil {
clifmt.Printf("Error setting up: %v\n", err.Error())
fmt.Printf("Error setting up: %s\n", err)
os.Exit(1)
}
}
Expand All @@ -54,15 +53,13 @@ var RootCmd = &cobra.Command{
Long: `Forge is a CLI tool for executing, in a consistent manner, scripts and commands for building and maintaining projects.`,
Args: cobra.MinimumNArgs(1),
RunE: rootFunc,
SilenceErrors: true,
ValidArgsFunction: validArgsFunc,
}

// 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.
func Execute() {
if err := RootCmd.Execute(); err != nil {
clifmt.Printf("Failed to execute: %v\n", err.Error())
os.Exit(1)
}
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/version.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package cmd

import (
"github.com/spf13/cobra"
"fmt"

"github.com/gomicro/forge/fmt"
"github.com/spf13/cobra"
)

func init() {
Expand All @@ -25,8 +25,8 @@ var versionCmd = &cobra.Command{

func versionFunc(cmd *cobra.Command, args []string) {
if Version == "" {
fmt.Printf("Forge version dev-local")
fmt.Printf("Forge version dev-local\n")
} else {
fmt.Printf("Forge version %v", Version)
fmt.Printf("Forge version %v\n", Version)
}
}
20 changes: 0 additions & 20 deletions fmt/fmt.go

This file was deleted.

Loading