Skip to content

Commit 96f8aae

Browse files
authored
Merge pull request #700 from sayanchowdhury/deprecate-cobra
Replace cobra with built-in flag
2 parents d7dff12 + 01fea1f commit 96f8aae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+17
-6418
lines changed

glide.lock

Lines changed: 2 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

glide.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ import:
2727
# Transitive dependency from aws-sdk-go:v1.8.39
2828
- package: github.com/jmespath/go-jmespath
2929
version: 0b12d6b521d83fc7f755e7cfc1b1fbdd35a01a74
30-
- package: github.com/spf13/cobra
31-
version: 0.0.1
32-
- package: github.com/spf13/pflag
33-
version: 1.0.0
3430
# see https://github.com/Masterminds/glide/issues/564 on why this is not
3531
# in testImport
3632
- package: github.com/pborman/uuid

validate/main.go

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,32 @@
1515
package main
1616

1717
import (
18+
"flag"
1819
"fmt"
1920
"io/ioutil"
2021
"os"
2122
"strings"
2223

2324
config "github.com/coreos/ignition/config/v3_0_experimental"
2425
"github.com/coreos/ignition/internal/version"
25-
26-
"github.com/spf13/cobra"
2726
)
2827

2928
var (
3029
flagVersion bool
31-
rootCmd = &cobra.Command{
32-
Use: "ignition-validate config.ign",
33-
Short: "ignition-validate will validate Ignition configs",
34-
Run: runIgnValidate,
35-
}
3630
)
3731

32+
func init() {
33+
flag.BoolVar(&flagVersion, "version", false, "print the version of ignition-validate")
34+
flag.Usage = func() {
35+
fmt.Fprintf(flag.CommandLine.Output(), "Usage:\n %s config.ign [flags]\n\n", os.Args[0])
36+
flag.PrintDefaults()
37+
}
38+
}
39+
3840
func main() {
39-
rootCmd.Flags().BoolVar(&flagVersion, "version", false, "print the version of ignition-validate")
40-
rootCmd.Execute()
41+
flag.Parse()
42+
43+
runIgnValidate(os.Args[1:])
4144
}
4245

4346
func stdout(format string, a ...interface{}) {
@@ -53,13 +56,14 @@ func die(format string, a ...interface{}) {
5356
os.Exit(1)
5457
}
5558

56-
func runIgnValidate(cmd *cobra.Command, args []string) {
59+
func runIgnValidate(args []string) {
5760
if flagVersion {
5861
stdout(version.String)
5962
return
6063
}
64+
6165
if len(args) != 1 {
62-
cmd.Usage()
66+
flag.Usage()
6367
os.Exit(1)
6468
}
6569
var blob []byte

vendor/github.com/inconshreveable/mousetrap/LICENSE

Lines changed: 0 additions & 13 deletions
This file was deleted.

vendor/github.com/inconshreveable/mousetrap/trap_others.go

Lines changed: 0 additions & 15 deletions
This file was deleted.

vendor/github.com/inconshreveable/mousetrap/trap_windows.go

Lines changed: 0 additions & 98 deletions
This file was deleted.

vendor/github.com/inconshreveable/mousetrap/trap_windows_1.4.go

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)