mirror of https://github.com/spf13/cobra.git
parent
7bd35d3b95
commit
db6b9a8b3f
|
@ -40,15 +40,19 @@ and the appropriate structure for a Cobra-based CLI application.
|
||||||
Init will not use an existing directory with contents.`,
|
Init will not use an existing directory with contents.`,
|
||||||
|
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
var project *Project
|
|
||||||
if len(args) == 0 {
|
|
||||||
wd, err := os.Getwd()
|
wd, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
er(err)
|
er(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var project *Project
|
||||||
|
if len(args) == 0 {
|
||||||
project = NewProjectFromPath(wd)
|
project = NewProjectFromPath(wd)
|
||||||
} else if len(args) == 1 {
|
} else if len(args) == 1 {
|
||||||
arg := args[0]
|
arg := args[0]
|
||||||
|
if arg[0] == '.' {
|
||||||
|
arg = filepath.Join(wd, arg)
|
||||||
|
}
|
||||||
if filepath.IsAbs(arg) {
|
if filepath.IsAbs(arg) {
|
||||||
project = NewProjectFromPath(arg)
|
project = NewProjectFromPath(arg)
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue