diff --git a/main.go b/main.go index a35d4cf..52232c7 100644 --- a/main.go +++ b/main.go @@ -8,9 +8,8 @@ import ( ) func main() { - cmd := cli.NewRootCmd() - if err := cmd.Execute(); err != nil { - fmt.Println(err) + if err := cli.Execute(); err != nil { + fmt.Fprint(os.Stderr, err) os.Exit(1) } } diff --git a/pkg/cli/cmd.go b/pkg/cli/cmd.go index 7bd8504..0c66282 100644 --- a/pkg/cli/cmd.go +++ b/pkg/cli/cmd.go @@ -12,6 +12,21 @@ import ( // TODO: allow setting with flag const MAX_TOKENS = 256 +func init() { + rootCmd.AddCommand( + lsCmd, + newCmd, + promptCmd, + replyCmd, + rmCmd, + viewCmd, + ) +} + +func Execute() error { + return rootCmd.Execute() +} + var rootCmd = &cobra.Command{ Use: "lmcli", Short: "Interact with Large Language Models", @@ -223,8 +238,8 @@ var replyCmd = &cobra.Command{ messageContents, err := InputFromEditor("# How would you like to reply?\n", "reply.*.md") userReply := Message{ - ConversationID: conversation.ID, - Role: "user", + ConversationID: conversation.ID, + Role: "user", OriginalContent: messageContents, } @@ -387,15 +402,3 @@ var promptCmd = &cobra.Command{ fmt.Println() }, } - -func NewRootCmd() *cobra.Command { - rootCmd.AddCommand( - lsCmd, - newCmd, - promptCmd, - replyCmd, - rmCmd, - viewCmd, - ) - return rootCmd -}