Skip to content

About subcommand directory #106

@mloskot

Description

@mloskot

This is transfer of @fanux's spf13/cobra#1059 as suggested there by @johnSchnake


➜  app cobra add create
create created at /Users/fanux/work/src/app/cmd/create.go
➜  app cobra add user -p create
user created at /Users/fanux/work/src/app/cmd/user.go
➜  app tree
.
├── LICENSE
├── cmd
│   ├── create.go
│   ├── root.go
│   └── user.go
└── main.go

cobra generates subcommand user in the same dir of its parent dir, it not very nice.

If I add a command user this user command is not create subcommand:

 cobra add user
Error: /Users/fanux/work/src/app/cmd/user.go already exists

So I think, create subcommand in a sub dir is better, like this:

.
├── LICENSE
├── cmd
│   ├── create.go
│   ├── root.go
|   |---create
│       └── user.go
└── main.go

This will not conflict

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions