-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix CLI interface, now with subcommands 'all' and 'crdsplit'
- Loading branch information
Showing
6 changed files
with
286 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.state | ||
bin | ||
test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/go-ksplit/ksplit/pkg" | ||
"github.com/pkg/errors" | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
func AllSplitCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "all", | ||
Short: "split kubernetes yaml within a directory", | ||
Long: `ksplit reformats generated kubernetes yaml into a more easily readable file format`, | ||
Example: "ksplit all myk8syamldir/", | ||
SilenceErrors: true, | ||
PreRun: func(cmd *cobra.Command, args []string) { | ||
viper.BindPFlags(cmd.Flags()) | ||
}, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
if len(args) == 0 { | ||
cmd.Help() | ||
return errors.New("Please supply a directory") | ||
} | ||
|
||
err := pkg.MaybeSplitMultidocYamlFs(args[0]) | ||
if err != nil { | ||
return errors.Wrap(err, "allsplit cmd") | ||
} | ||
return nil | ||
}, | ||
} | ||
|
||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/go-ksplit/ksplit/pkg" | ||
"github.com/pkg/errors" | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
func CrdSplitCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "crdsplit", | ||
Short: "split CRDs from non-CRD files", | ||
Long: `...`, | ||
Example: "ksplit crdsplit myk8syamldir/", | ||
SilenceErrors: true, | ||
PreRun: func(cmd *cobra.Command, args []string) { | ||
viper.BindPFlags(cmd.Flags()) | ||
}, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
if len(args) == 0 { | ||
cmd.Help() | ||
return errors.New("Please supply a directory") | ||
} | ||
|
||
err := pkg.MaybeSplitCRDsFs(args[0]) | ||
if err != nil { | ||
return errors.Wrap(err, "crdsplit cmd") | ||
} | ||
return nil | ||
}, | ||
} | ||
|
||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.