mirror of
https://github.com/spf13/cobra
synced 2025-07-01 00:27:23 +00:00
Rename packages to use OneCloud
This commit is contained in:
parent
7547e83b2d
commit
9224a9a8f3
31 changed files with 111 additions and 56 deletions
|
@ -2,7 +2,7 @@ version: 2
|
|||
|
||||
references:
|
||||
workspace: &workspace
|
||||
/go/src/github.com/spf13/cobra
|
||||
/go/src/github.com/OneCloudInc/cobra
|
||||
|
||||
run_tests: &run_tests
|
||||
run:
|
||||
|
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -34,3 +34,5 @@ tags
|
|||
*.exe
|
||||
|
||||
cobra.test
|
||||
|
||||
.idea
|
||||
|
|
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
20
README.md
20
README.md
|
@ -24,7 +24,7 @@ Many of the most widely used Go projects are built using Cobra including:
|
|||
|
||||
[](https://travis-ci.org/spf13/cobra)
|
||||
[](https://circleci.com/gh/spf13/cobra)
|
||||
[](https://godoc.org/github.com/spf13/cobra)
|
||||
[](https://godoc.org/github.com/OneCloudInc/cobra)
|
||||
|
||||
# Table of Contents
|
||||
|
||||
|
@ -103,7 +103,7 @@ have children commands and optionally run an action.
|
|||
|
||||
In the example above, 'server' is the command.
|
||||
|
||||
[More about cobra.Command](https://godoc.org/github.com/spf13/cobra#Command)
|
||||
[More about cobra.Command](https://godoc.org/github.com/OneCloudInc/cobra#Command)
|
||||
|
||||
## Flags
|
||||
|
||||
|
@ -123,12 +123,12 @@ Using Cobra is easy. First, use `go get` to install the latest version
|
|||
of the library. This command will install the `cobra` generator executable
|
||||
along with the library and its dependencies:
|
||||
|
||||
go get -u github.com/spf13/cobra/cobra
|
||||
go get -u github.com/OneCloudInc/cobra/cobra
|
||||
|
||||
Next, include Cobra in your application:
|
||||
|
||||
```go
|
||||
import "github.com/spf13/cobra"
|
||||
import "github.com/OneCloudInc/cobra"
|
||||
```
|
||||
|
||||
# Getting Started
|
||||
|
@ -165,7 +165,7 @@ func main() {
|
|||
Cobra provides its own program that will create your application and add any
|
||||
commands you want. It's the easiest way to incorporate Cobra into your application.
|
||||
|
||||
[Here](https://github.com/spf13/cobra/blob/master/cobra/README.md) you can find more information about it.
|
||||
[Here](https://github.com/OneCloudInc/cobra/blob/master/cobra/README.md) you can find more information about it.
|
||||
|
||||
## Using the Cobra Library
|
||||
|
||||
|
@ -208,7 +208,7 @@ import (
|
|||
"os"
|
||||
|
||||
homedir "github.com/mitchellh/go-homedir"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/OneCloudInc/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
|
@ -284,7 +284,7 @@ package cmd
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/OneCloudInc/cobra"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -430,7 +430,7 @@ import (
|
|||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/OneCloudInc/cobra"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -597,7 +597,7 @@ package main
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/OneCloudInc/cobra"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -728,4 +728,4 @@ Cobra can generate a bash-completion file. If you add more information to your c
|
|||
|
||||
# License
|
||||
|
||||
Cobra is released under the Apache 2.0 license. See [LICENSE.txt](https://github.com/spf13/cobra/blob/master/LICENSE.txt)
|
||||
Cobra is released under the Apache 2.0 license. See [LICENSE.txt](https://github.com/OneCloudInc/cobra/blob/master/LICENSE.txt)
|
||||
|
|
|
@ -5,7 +5,7 @@ commands you want. It's the easiest way to incorporate Cobra into your applicati
|
|||
|
||||
In order to use the cobra command, compile it using the following command:
|
||||
|
||||
go get github.com/spf13/cobra/cobra
|
||||
go get github.com/OneCloudInc/cobra/cobra
|
||||
|
||||
This will create the cobra executable under your `$GOPATH/bin` directory.
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ import (
|
|||
"path/filepath"
|
||||
"unicode"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/OneCloudInc/cobra"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
|
|
@ -19,7 +19,7 @@ import (
|
|||
"path"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/OneCloudInc/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
|
@ -144,7 +144,7 @@ import (
|
|||
"os"
|
||||
{{if .viper}}
|
||||
homedir "github.com/mitchellh/go-homedir"{{end}}
|
||||
"github.com/spf13/cobra"{{if .viper}}
|
||||
"github.com/OneCloudInc/cobra"{{if .viper}}
|
||||
"github.com/spf13/viper"{{end}}
|
||||
){{if .viper}}
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ func (p *Project) License() License {
|
|||
return p.license
|
||||
}
|
||||
|
||||
// Name returns the name of project, e.g. "github.com/spf13/cobra"
|
||||
// Name returns the name of project, e.g. "github.com/OneCloudInc/cobra"
|
||||
func (p Project) Name() string {
|
||||
return p.name
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
)
|
||||
|
||||
func TestFindExistingPackage(t *testing.T) {
|
||||
path := findPackage("github.com/spf13/cobra")
|
||||
path := findPackage("github.com/OneCloudInc/cobra")
|
||||
if path == "" {
|
||||
t.Fatal("findPackage didn't find the existing package")
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ import (
|
|||
"fmt"
|
||||
|
||||
homedir "github.com/mitchellh/go-homedir"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/OneCloudInc/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
|
|
47
cobra/cmd/test.go
Normal file
47
cobra/cmd/test.go
Normal file
|
@ -0,0 +1,47 @@
|
|||
// Copyright © 2019 NAME HERE <EMAIL ADDRESS>
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/OneCloudInc/cobra"
|
||||
)
|
||||
|
||||
var testqueryIdFlag string
|
||||
var testparamsFlag stringMap
|
||||
|
||||
|
||||
func init() {
|
||||
testCmd.Flags().StringVar(&testqueryIdFlag, "queryId", "", "Query ID")
|
||||
testCmd.Flags().StringMapVar(&testparamsFlag, "params", "", "Params")
|
||||
|
||||
rootCmd.AddCommand(testCmd)
|
||||
}
|
||||
|
||||
// testCmd represents the test command
|
||||
var testCmd = &cobra.Command{
|
||||
Use: "test",
|
||||
Short: "A brief description of your command",
|
||||
Long: `A longer description that spans multiple lines and likely contains examples
|
||||
and usage of using your command. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("test called")
|
||||
},
|
||||
}
|
2
cobra/cmd/testdata/root.go.golden
vendored
2
cobra/cmd/testdata/root.go.golden
vendored
|
@ -19,7 +19,7 @@ import (
|
|||
"os"
|
||||
|
||||
homedir "github.com/mitchellh/go-homedir"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/OneCloudInc/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
|
|
2
cobra/cmd/testdata/test.go.golden
vendored
2
cobra/cmd/testdata/test.go.golden
vendored
|
@ -17,7 +17,7 @@ package cmd
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/OneCloudInc/cobra"
|
||||
)
|
||||
|
||||
// testCmd represents the test command
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
package main
|
||||
|
||||
import "github.com/spf13/cobra/cobra/cmd"
|
||||
import "github.com/OneCloudInc/cobra/cobra/cmd"
|
||||
|
||||
func main() {
|
||||
cmd.Execute()
|
||||
|
|
|
@ -1223,7 +1223,7 @@ func (c *Command) IsAvailableCommand() bool {
|
|||
// help topic command; additional help topic command is determined by the
|
||||
// fact that it is NOT runnable/hidden/deprecated, and has no sub commands that
|
||||
// are runnable/hidden/deprecated.
|
||||
// Concrete example: https://github.com/spf13/cobra/issues/393#issuecomment-282741924.
|
||||
// Concrete example: https://github.com/OneCloudInc/cobra/issues/393#issuecomment-282741924.
|
||||
func (c *Command) IsAdditionalHelpTopicCommand() bool {
|
||||
// if a command is runnable, deprecated, or hidden it is not a 'help' command
|
||||
if c.Runnable() || len(c.Deprecated) != 0 || c.Hidden {
|
||||
|
|
|
@ -805,7 +805,7 @@ func TestHelpFlagExecutedOnChild(t *testing.T) {
|
|||
// TestHelpFlagInHelp checks,
|
||||
// if '--help' flag is shown in help for child (executing `parent help child`),
|
||||
// that has no other flags.
|
||||
// Related to https://github.com/spf13/cobra/issues/302.
|
||||
// Related to https://github.com/OneCloudInc/cobra/issues/302.
|
||||
func TestHelpFlagInHelp(t *testing.T) {
|
||||
parentCmd := &Command{Use: "parent", Run: func(*Command, []string) {}}
|
||||
|
||||
|
@ -1166,7 +1166,7 @@ func TestPersistentHooks(t *testing.T) {
|
|||
|
||||
// TODO: currently PersistenPreRun* defined in parent does not
|
||||
// run if the matchin child subcommand has PersistenPreRun.
|
||||
// If the behavior changes (https://github.com/spf13/cobra/issues/252)
|
||||
// If the behavior changes (https://github.com/OneCloudInc/cobra/issues/252)
|
||||
// this test must be fixed.
|
||||
if parentPersPreArgs != "" {
|
||||
t.Errorf("Expected blank parentPersPreArgs, got %q", parentPersPreArgs)
|
||||
|
@ -1182,7 +1182,7 @@ func TestPersistentHooks(t *testing.T) {
|
|||
}
|
||||
// TODO: currently PersistenPostRun* defined in parent does not
|
||||
// run if the matchin child subcommand has PersistenPostRun.
|
||||
// If the behavior changes (https://github.com/spf13/cobra/issues/252)
|
||||
// If the behavior changes (https://github.com/OneCloudInc/cobra/issues/252)
|
||||
// this test must be fixed.
|
||||
if parentPersPostArgs != "" {
|
||||
t.Errorf("Expected blank parentPersPostArgs, got %q", parentPersPostArgs)
|
||||
|
@ -1205,7 +1205,7 @@ func TestPersistentHooks(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// Related to https://github.com/spf13/cobra/issues/521.
|
||||
// Related to https://github.com/OneCloudInc/cobra/issues/521.
|
||||
func TestGlobalNormFuncPropagation(t *testing.T) {
|
||||
normFunc := func(f *pflag.FlagSet, name string) pflag.NormalizedName {
|
||||
return pflag.NormalizedName(name)
|
||||
|
@ -1225,7 +1225,7 @@ func TestGlobalNormFuncPropagation(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// Related to https://github.com/spf13/cobra/issues/521.
|
||||
// Related to https://github.com/OneCloudInc/cobra/issues/521.
|
||||
func TestNormPassedOnLocal(t *testing.T) {
|
||||
toUpper := func(f *pflag.FlagSet, name string) pflag.NormalizedName {
|
||||
return pflag.NormalizedName(strings.ToUpper(name))
|
||||
|
@ -1239,7 +1239,7 @@ func TestNormPassedOnLocal(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// Related to https://github.com/spf13/cobra/issues/521.
|
||||
// Related to https://github.com/OneCloudInc/cobra/issues/521.
|
||||
func TestNormPassedOnInherited(t *testing.T) {
|
||||
toUpper := func(f *pflag.FlagSet, name string) pflag.NormalizedName {
|
||||
return pflag.NormalizedName(strings.ToUpper(name))
|
||||
|
@ -1267,7 +1267,7 @@ func TestNormPassedOnInherited(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// Related to https://github.com/spf13/cobra/issues/521.
|
||||
// Related to https://github.com/OneCloudInc/cobra/issues/521.
|
||||
func TestConsistentNormalizedName(t *testing.T) {
|
||||
toUpper := func(f *pflag.FlagSet, name string) pflag.NormalizedName {
|
||||
return pflag.NormalizedName(strings.ToUpper(name))
|
||||
|
@ -1400,7 +1400,7 @@ func TestFlagErrorFunc(t *testing.T) {
|
|||
|
||||
// TestSortedFlags checks,
|
||||
// if cmd.LocalFlags() is unsorted when cmd.Flags().SortFlags set to false.
|
||||
// Related to https://github.com/spf13/cobra/issues/404.
|
||||
// Related to https://github.com/OneCloudInc/cobra/issues/404.
|
||||
func TestSortedFlags(t *testing.T) {
|
||||
c := &Command{}
|
||||
c.Flags().SortFlags = false
|
||||
|
@ -1426,7 +1426,7 @@ func TestSortedFlags(t *testing.T) {
|
|||
// TestMergeCommandLineToFlags checks,
|
||||
// if pflag.CommandLine is correctly merged to c.Flags() after first call
|
||||
// of c.mergePersistentFlags.
|
||||
// Related to https://github.com/spf13/cobra/issues/443.
|
||||
// Related to https://github.com/OneCloudInc/cobra/issues/443.
|
||||
func TestMergeCommandLineToFlags(t *testing.T) {
|
||||
pflag.Bool("boolflag", false, "")
|
||||
c := &Command{Use: "c", Run: emptyRun}
|
||||
|
@ -1440,7 +1440,7 @@ func TestMergeCommandLineToFlags(t *testing.T) {
|
|||
|
||||
// TestUseDeprecatedFlags checks,
|
||||
// if cobra.Execute() prints a message, if a deprecated flag is used.
|
||||
// Related to https://github.com/spf13/cobra/issues/463.
|
||||
// Related to https://github.com/OneCloudInc/cobra/issues/463.
|
||||
func TestUseDeprecatedFlags(t *testing.T) {
|
||||
c := &Command{Use: "c", Run: emptyRun}
|
||||
c.Flags().BoolP("deprecated", "d", false, "deprecated flag")
|
||||
|
@ -1555,7 +1555,7 @@ func TestTraverseWithTwoSubcommands(t *testing.T) {
|
|||
}
|
||||
|
||||
// TestUpdateName checks if c.Name() updates on changed c.Use.
|
||||
// Related to https://github.com/spf13/cobra/pull/422#discussion_r143918343.
|
||||
// Related to https://github.com/OneCloudInc/cobra/pull/422#discussion_r143918343.
|
||||
func TestUpdateName(t *testing.T) {
|
||||
c := &Command{Use: "name xyz"}
|
||||
originalName := c.Name()
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/OneCloudInc/cobra"
|
||||
)
|
||||
|
||||
func emptyRun(*cobra.Command, []string) {}
|
||||
|
|
|
@ -25,7 +25,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/cpuguy83/go-md2man/md2man"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/OneCloudInc/cobra"
|
||||
"github.com/spf13/pflag"
|
||||
)
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@ package main
|
|||
import (
|
||||
"log"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/cobra/doc"
|
||||
"github.com/OneCloudInc/cobra"
|
||||
"github.com/OneCloudInc/cobra/doc"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/OneCloudInc/cobra"
|
||||
)
|
||||
|
||||
func translate(in string) string {
|
||||
|
|
|
@ -4,8 +4,8 @@ import (
|
|||
"bytes"
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/cobra/doc"
|
||||
"github.com/OneCloudInc/cobra"
|
||||
"github.com/OneCloudInc/cobra/doc"
|
||||
)
|
||||
|
||||
func ExampleGenManTree() {
|
||||
|
|
|
@ -23,7 +23,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/OneCloudInc/cobra"
|
||||
)
|
||||
|
||||
func printOptions(buf *bytes.Buffer, cmd *cobra.Command, name string) error {
|
||||
|
|
|
@ -8,8 +8,8 @@ package main
|
|||
import (
|
||||
"log"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/cobra/doc"
|
||||
"github.com/OneCloudInc/cobra"
|
||||
"github.com/OneCloudInc/cobra/doc"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -41,7 +41,7 @@ import (
|
|||
"k8s.io/kubernetes/pkg/kubectl/cmd"
|
||||
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
|
||||
|
||||
"github.com/spf13/cobra/doc"
|
||||
"github.com/OneCloudInc/cobra/doc"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/OneCloudInc/cobra"
|
||||
)
|
||||
|
||||
func TestGenMdDoc(t *testing.T) {
|
||||
|
|
|
@ -23,7 +23,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/OneCloudInc/cobra"
|
||||
)
|
||||
|
||||
func printOptionsReST(buf *bytes.Buffer, cmd *cobra.Command, name string) error {
|
||||
|
|
|
@ -8,8 +8,8 @@ package main
|
|||
import (
|
||||
"log"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/cobra/doc"
|
||||
"github.com/OneCloudInc/cobra"
|
||||
"github.com/OneCloudInc/cobra/doc"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -41,7 +41,7 @@ import (
|
|||
"k8s.io/kubernetes/pkg/kubectl/cmd"
|
||||
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
|
||||
|
||||
"github.com/spf13/cobra/doc"
|
||||
"github.com/OneCloudInc/cobra/doc"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/OneCloudInc/cobra"
|
||||
)
|
||||
|
||||
func TestGenRSTDoc(t *testing.T) {
|
||||
|
|
|
@ -16,7 +16,7 @@ package doc
|
|||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/OneCloudInc/cobra"
|
||||
)
|
||||
|
||||
// Test to see if we have a reason to print See Also information in docs
|
||||
|
|
|
@ -21,7 +21,7 @@ import (
|
|||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/OneCloudInc/cobra"
|
||||
"github.com/spf13/pflag"
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
|
|
@ -8,8 +8,8 @@ package main
|
|||
import (
|
||||
"log"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/cobra/doc"
|
||||
"github.com/OneCloudInc/cobra"
|
||||
"github.com/OneCloudInc/cobra/doc"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -41,7 +41,7 @@ import (
|
|||
"k8s.io/kubernetes/pkg/kubectl/cmd"
|
||||
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
|
||||
|
||||
"github.com/spf13/cobra/doc"
|
||||
"github.com/OneCloudInc/cobra/doc"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/OneCloudInc/cobra"
|
||||
)
|
||||
|
||||
func TestGenYamlDoc(t *testing.T) {
|
||||
|
|
Loading…
Add table
Reference in a new issue