github.com/hrntknr/ntf@v1.0.2-0.20220725163249-d52a7861d93d/main.go (about)

     1  package main
     2  
     3  import (
     4  	_ "embed"
     5  	"log"
     6  
     7  	"github.com/hrntknr/ntf/backends"
     8  	"github.com/spf13/cobra"
     9  )
    10  
    11  func main() {
    12  	if err := _main(); err != nil {
    13  		log.Fatal(err)
    14  	}
    15  }
    16  
    17  //go:embed ntf-shell-hook.sh
    18  var ntf_shell_hook []byte
    19  
    20  func _main() error {
    21  	cmd := &cobra.Command{}
    22  	cmd.CompletionOptions.DisableDefaultCmd = true
    23  
    24  	doneCmd := &cobra.Command{
    25  		Use:   "done",
    26  		Short: "Execute the command and notify the message",
    27  		Run:   doneFunc,
    28  	}
    29  	doneCmd.Flags().StringP("title", "t", "", "override title")
    30  
    31  	sendCmd := &cobra.Command{
    32  		Use:   "send",
    33  		Short: "send notification",
    34  		Run:   sendFunc,
    35  	}
    36  	sendCmd.Flags().StringP("title", "t", "", "override title")
    37  
    38  	shellDoneCmd := &cobra.Command{
    39  		Use:    "shell-done",
    40  		Hidden: true,
    41  		Run:    shellDoneFunc,
    42  	}
    43  	shellDoneCmd.Flags().StringP("title", "t", "", "override title")
    44  
    45  	shellIntegrationCmd := &cobra.Command{
    46  		Use:   "shell-integration",
    47  		Short: "shell-integration",
    48  		Run:   shellIntegrationFunc,
    49  	}
    50  
    51  	backends.RegisterFlags(doneCmd, sendCmd, shellIntegrationCmd, shellDoneCmd)
    52  	cmd.AddCommand(doneCmd, sendCmd, shellIntegrationCmd, shellDoneCmd)
    53  	return cmd.Execute()
    54  }