Show help when command is specified

This commit is contained in:
Kovid Goyal 2022-08-14 18:47:01 +05:30
parent bbf7504303
commit c97556de65
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"os" "os"
"github.com/fatih/color"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"kitty/tools/cli" "kitty/tools/cli"
@ -11,6 +12,7 @@ import (
) )
var encrypt_cmd = crypto.Encrypt_cmd var encrypt_cmd = crypto.Encrypt_cmd
var exe_name = "kitty-at"
func main() { func main() {
var root = cli.CreateCommand(&cobra.Command{ var root = cli.CreateCommand(&cobra.Command{
@ -18,10 +20,10 @@ func main() {
Short: "Control kitty remotely", Short: "Control kitty remotely",
Long: "Control kitty by sending it commands. Set the allow_remote_control option in kitty.conf or use a password, for this to work.", Long: "Control kitty by sending it commands. Set the allow_remote_control option in kitty.conf or use a password, for this to work.",
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
use_password, _ := cmd.Flags().GetString("use-password") cmd.Usage()
fmt.Println("In global run, use-password:", use_password) fmt.Fprintln(os.Stderr, color.RedString("\nNo command specified for " + exe_name))
}, },
}, "kitty-at") }, exe_name)
cli.PersistentChoices(root, "use-password", "If no password is available, kitty will usually just send the remote control command without a password. This option can be used to force it to always or never use the supplied password.", "if-available", "always", "never") cli.PersistentChoices(root, "use-password", "If no password is available, kitty will usually just send the remote control command without a password. This option can be used to force it to always or never use the supplied password.", "if-available", "always", "never")
root.Annotations["options_title"] = "Global options" root.Annotations["options_title"] = "Global options"
cli.Init(root) cli.Init(root)