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