<commit_before>package main

import (
	"errors"
	"fmt"
	"net/url"
	"os/exec"
	"strings"
)

const (
	binaryPath = "osx/terminal-notifier-{type}.app/Contents/MacOS/terminal-notifier"
)

type MessageType string

const (
	Fail MessageType = "fail"
	Info MessageType = "info"
	Pass MessageType = "pass"
)

type Sound string

const (
	Default Sound = "default"
	Basso   Sound = "Basso"
	Blow    Sound = "Blow"
	Bottle  Sound = "Bottle"
	Frog    Sound = "Frog"
	Funk    Sound = "Funk"
	Glass   Sound = "Glass"
	Hero    Sound = "Hero"
	Morse   Sound = "Morse"
	Ping    Sound = "Ping"
	Pop     Sound = "Pop"
	Purr    Sound = "Purr"
	Sosumi  Sound = "Sosumi"
	Tink    Sound = "Tink"
)

type Notification struct {
	Type     MessageType //required
	Message  string      //required
	Title    string      //optional
	Subtitle string      //optional
	Sound    Sound       //optional
	Link     string      //optional
}

func NewNotification(messageType MessageType, message string) *Notification {
	n := &Notification{Type: messageType, Message: message}
	return n
}

func (n *Notification) SendNotification() error {

	commandTuples := make([]string, 0)

	//check required commands
	if n.Message == "" {
		return errors.New("Please specifiy a proper message argument.")
	} else {
		commandTuples = append(commandTuples, []string{"-message", n.Message}...)
	}

	//add title if found
	if n.Title != "" {
		commandTuples = append(commandTuples, []string{"-title", n.Title}...)
	}

	//add subtitle if found
	if n.Subtitle != "" {
		commandTuples = append(commandTuples, []string{"-subtitle", n.Subtitle}...)
	}

	//add sound if specified
	if n.Sound != "" {
		commandTuples = append(commandTuples, []string{"-sound", string(n.Sound)}...)
	}

	//add url if specified
	url, err := url.Parse(n.Link)
	if err != nil {
		n.Link = ""
	}
	if url != nil {
		commandTuples = append(commandTuples, []string{"-open", n.Link}...)
	}

	//add bundle id if specified
	if strings.HasPrefix(strings.ToLower(n.Link), "com.") {
		commandTuples = append(commandTuples, []string{"-activate", n.Link}...)
	}

	if len(commandTuples) == 0 {
		return errors.New("Please provide a Message and Type at a minimum.")
	}

	bPath := strings.Replace(binaryPath, "{type}", string(n.Type), -1)

	_, err := exec.Command(bPath, commandTuples...).Output()
	if err != nil {
		return err
	}

	return nil
}

func main() {

	note := NewNotification(Info, "Check your Apple Stock!")
	note.Title = "💰" //Cool emojis
	note.Subtitle = "My subtitle"
	note.Sound = Basso
	note.Link = "http://www.yahoo.com" //or BundleID like: com.apple.Safari

	err := note.SendNotification()

	if err != nil {
		fmt.Println(err)
	}

	//TODO: need to add the commands to a command slice
	//then call the exec.Command with the slice separated ...(like a params object)
}<commit_msg>Removed main and changed package name<commit_after>package gosxnotifier

import (
	"errors"
	"fmt"
	"net/url"
	"os/exec"
	"strings"
)

const (
	binaryPath = "osx/terminal-notifier-{type}.app/Contents/MacOS/terminal-notifier"
)

type MessageType string

const (
	Fail MessageType = "fail"
	Info MessageType = "info"
	Pass MessageType = "pass"
)

type Sound string

const (
	Default Sound = "default"
	Basso   Sound = "Basso"
	Blow    Sound = "Blow"
	Bottle  Sound = "Bottle"
	Frog    Sound = "Frog"
	Funk    Sound = "Funk"
	Glass   Sound = "Glass"
	Hero    Sound = "Hero"
	Morse   Sound = "Morse"
	Ping    Sound = "Ping"
	Pop     Sound = "Pop"
	Purr    Sound = "Purr"
	Sosumi  Sound = "Sosumi"
	Tink    Sound = "Tink"
)

type Notification struct {
	Type     MessageType //required
	Message  string      //required
	Title    string      //optional
	Subtitle string      //optional
	Sound    Sound       //optional
	Link     string      //optional
}

func NewNotification(messageType MessageType, message string) *Notification {
	n := &Notification{Type: messageType, Message: message}
	return n
}

func (n *Notification) SendNotification() error {

	commandTuples := make([]string, 0)

	//check required commands
	if n.Message == "" {
		return errors.New("Please specifiy a proper message argument.")
	} else {
		commandTuples = append(commandTuples, []string{"-message", n.Message}...)
	}

	//add title if found
	if n.Title != "" {
		commandTuples = append(commandTuples, []string{"-title", n.Title}...)
	}

	//add subtitle if found
	if n.Subtitle != "" {
		commandTuples = append(commandTuples, []string{"-subtitle", n.Subtitle}...)
	}

	//add sound if specified
	if n.Sound != "" {
		commandTuples = append(commandTuples, []string{"-sound", string(n.Sound)}...)
	}

	//add url if specified
	url, err := url.Parse(n.Link)
	if err != nil {
		n.Link = ""
	}
	if url != nil {
		commandTuples = append(commandTuples, []string{"-open", n.Link}...)
	}

	//add bundle id if specified
	if strings.HasPrefix(strings.ToLower(n.Link), "com.") {
		commandTuples = append(commandTuples, []string{"-activate", n.Link}...)
	}

	if len(commandTuples) == 0 {
		return errors.New("Please provide a Message and Type at a minimum.")
	}

	bPath := strings.Replace(binaryPath, "{type}", string(n.Type), -1)

	_, err = exec.Command(bPath, commandTuples...).Output()
	if err != nil {
		return err
	}

	return nil
}
{'fraction_non_alphanumeric': 0.14742724995182116, 'fraction_numerical': 0.0011562921564848719, 'mean_word_length': 3.250614250614251, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2925866', 'n_tokens_mistral': 1890, 'n_tokens_neox': 1794, 'n_words': 490}