Example #1
0
//
// 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())
}
Example #2
0
//
// 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())
}