Skip to content

Commit

Permalink
Tidy up the mod init command
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Prodan <[email protected]>
  • Loading branch information
stefanprodan committed Nov 17, 2023
1 parent c9f760e commit 63eae98
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions cmd/timoni/mod_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ import (
var initModCmd = &cobra.Command{
Use: "init [MODULE NAME] [PATH]",
Short: "Create a module along with common files and directories",
Example: ` # create a module in the current directory
timoni mod init my-app .
Example: ` # Create a module in the current directory
timoni mod init my-app
# Create a module at the specified path
timoni mod init my-app ./modules
`,
RunE: runInitModCmd,
}
Expand All @@ -56,12 +59,16 @@ const (
)

func runInitModCmd(cmd *cobra.Command, args []string) error {
if len(args) < 2 {
return fmt.Errorf("module name and path are required")
if len(args) < 1 {
return fmt.Errorf("module name is required")
}

initModArgs.name = args[0]
initModArgs.path = args[1]

if len(args) == 2 {
initModArgs.path = args[1]
} else {
initModArgs.path = "."
}

log := LoggerFrom(cmd.Context())

Expand Down

0 comments on commit 63eae98

Please sign in to comment.