Skip to content

Commit 7a9d73e

Browse files
authored
apiviewgo: print help instead of panicking when given no args (#8333)
1 parent 8800d04 commit 7a9d73e

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

src/go/cmd/root.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,18 @@ import (
1212

1313
// rootCmd represents the base command when called without any subcommands
1414
var rootCmd = &cobra.Command{
15-
Use: "apiview <packageDir> <outputDir>",
16-
Short: "apiview will generate the JSON token output for APIView",
17-
Long: `The apiview command can be used to generate the tokenized
18-
output needed by the APIView tool to show a view of publicly
19-
exposed portions of an SDK. The generated file will use the
20-
following naming format: <module name>.json
21-
NOTE: This command will overwrite any file with the same name
22-
in the output directory.`,
23-
// Uncomment the following line if your bare application
24-
// has an action associated with it:
15+
Use: "apiviewgo <moduleDir> <outputDir>",
16+
Long: `apiviewgo outputs a file representing the public API of an Azure SDK for Go
17+
module in APIView format. It writes this file to <outputDir>/<module name>.json,
18+
overwriting any file of the same name.`,
2519
Run: func(cmd *cobra.Command, args []string) {
20+
if len(args) != 2 {
21+
err := cmd.Help()
22+
if err != nil {
23+
fmt.Println(err)
24+
}
25+
return
26+
}
2627
err := CreateAPIView(args[0], args[1])
2728
if err != nil {
2829
fmt.Println(err)

0 commit comments

Comments
 (0)