@@ -3,6 +3,7 @@ package cmd
33import (
44 "encoding/json"
55 "encoding/xml"
6+ "errors"
67 "fmt"
78 "io"
89 "os"
@@ -84,17 +85,7 @@ func runDescribe(cmd *cobra.Command, args []string, newClient ClientFactory) (er
8485 return err
8586 }
8687 if ! f .Initialized () {
87- return fmt .Errorf (`no function found in current directory.
88- You need to be inside a function directory to get the function description.
89-
90- Try this:
91- func create --language go myfunction Create a new function
92- cd myfunction Go into the function directory
93- func describe Show function description
94-
95- Or if you have an existing function:
96- cd path/to/your/function Go to your function directory
97- func describe Show function description` )
88+ return formatError (fn .NewErrNotInitialized (f .Root ))
9889 }
9990 details , err = client .Describe (cmd .Context (), "" , "" , f )
10091 if err != nil {
@@ -106,6 +97,32 @@ Or if you have an existing function:
10697 return
10798}
10899
100+ // formatError wraps ErrNotInitialized with user-friendly guidance
101+ func formatError (err error ) error {
102+ var errNotInitialized * fn.ErrNotInitialized
103+ if errors .As (err , & errNotInitialized ) {
104+ return fmt .Errorf (`%s
105+
106+ No function found in provided path (current directory or via --path).
107+ You need to be in a function directory (or use --path).
108+
109+ Try this:
110+ func create --language go myfunction Create a new function
111+ cd myfunction Go into the function directory
112+ func describe Show function description
113+
114+ Or if you have an existing function:
115+ cd path/to/your/function Go to your function directory
116+ func describe Show function description
117+
118+ Or use --path to describe from anywhere:
119+ func describe --path /path/to/function
120+
121+ For more information try 'func describe --help'` , errNotInitialized .Error ())
122+ }
123+ return err
124+ }
125+
109126// CLI Configuration (parameters)
110127// ------------------------------
111128
0 commit comments