コード例 #1
0
ファイル: feedback.go プロジェクト: brianroach/goAlfred
//
// Function:          main
//
// Description:       This is the main function that is called whenever the program is
//                           executed.
//
func main() {
	if len(os.Args) > 1 {
		switch os.Args[1] {
		case "1":
			goAlfred.AddResult("testUID1", "test argument1", "This is my title1", "test substring1", "icon.png", "yes", "", "")
			goAlfred.AddResult("testUID2", "test argument2", "This is my title2", "test substring2", "icon.png", "yes", "", "")
			goAlfred.AddResult("testUID3", "test argument3", "This is my title3", "test substring3", "icon.png", "yes", "", "")
		case "2":
			goAlfred.AddResult("testUID2", "test argument2", "This is my title2", "test substring2", "icon.png", "yes", "", "")
			goAlfred.AddResult("testUID1", "test argument1", "This is my title1", "test substring1", "icon.png", "yes", "", "")
			goAlfred.AddResult("testUID3", "test argument3", "This is my title3", "test substring3", "icon.png", "yes", "", "")
		case "3":
			goAlfred.AddResult("testUID3", "test argument3", "This is my title3", "test substring3", "icon.png", "yes", "", "")
			goAlfred.AddResult("testUID1", "test argument1", "This is my title1", "test substring1", "icon.png", "yes", "", "")
			goAlfred.AddResult("testUID2", "test argument2", "This is my title2", "test substring2", "icon.png", "yes", "", "")

		}
	} else {
		goAlfred.AddResult("testUID3", "test argument3", "This is my title3", "test substring3", "icon.png", "yes", "", "")
		goAlfred.AddResult("testUID", "test argument", "This is my title", "test substring", "icon.png", "yes", "", "")
		goAlfred.AddResult("testUID2", "test argument2", "This is my title2", "test substring2", "icon.png", "yes", "", "")
	}

	//
	// Print out the created XML.
	//
	fmt.Print(goAlfred.ToXML())
}
コード例 #2
0
ファイル: TimeKeeper.go プロジェクト: raguay/AfredTimekeeper
//
// Function:           state
//
// Description:       This function gives the proper output for changing the state. The state
//                            first is the one opposite from the current state.
//
func state() {
	//
	// Get the last state of the current project.
	//
	stateFile := getTimeSheetDir() + "/laststate.txt"
	buf, _ := ioutil.ReadFile(stateFile)
	curState := string(buf)

	//
	// Set the first command to the opposite of the current state. That way
	// the user simply pushes return to toggle states.
	//
	if strings.Contains(curState, "start") {
		goAlfred.AddResult("stop", "stop", "stop", "", "icon.png", "yes", "", "")
		goAlfred.AddResult("start", "start", "start", "", "icon.png", "yes", "", "")
	} else {
		goAlfred.AddResult("start", "start", "start", "", "icon.png", "yes", "", "")
		goAlfred.AddResult("stop", "stop", "stop", "", "icon.png", "yes", "", "")
	}

	//
	// Print out the xml string.
	//
	fmt.Print(goAlfred.ToXML())
}
コード例 #3
0
ファイル: TimeKeeper.go プロジェクト: raguay/AfredTimekeeper
//
// Function:           project
//
// Description:       This function creates a list of the projects and displays the ones
//                            similar to the input.
//
func project() {
	//
	// Get the project name from the command line.
	//
	proj := GetCommandLineString()

	//
	// Set our default string.
	//
	goAlfred.SetDefaultString("Alfred Time Keeper:  Sorry, no match...")

	//
	// Get the latest project.
	//
	latestproject := GetCurrentProject()

	//
	// Get the list of projects.
	//
	projects := make([]string, MAXPROJECTS)
	projects = GetListOfProjects()

	//
	// The regexp split statement gives one string more than was split out. The last
	// string is a catchall. It does not need to be included.
	//
	numproj := len(projects) - 1

	//
	// For each project, create a result line. Show all put the current project.
	//
	for i := 0; i < numproj; i++ {
		if !strings.Contains(projects[i], latestproject) || (latestproject == "") {
			goAlfred.AddResultsSimilar(proj, projects[i], projects[i], projects[i], "", "icon.png", "yes", "", "")
		}
	}

	//
	// Print out the xml string.
	//
	fmt.Print(goAlfred.ToXML())
}