コード例 #1
0
ファイル: commands.go プロジェクト: DrGo/samay
func addEntry(project *data.Project) (err error) {
	data.Save(project)
	entry := project.CreateEntryWithDuration(
		getContent(), duration, billable,
	)
	err = data.Save(entry)
	return
}
コード例 #2
0
ファイル: commands.go プロジェクト: DrGo/samay
func deleteEntry(project *data.Project) (err error) {
	for i, entry := range project.Entries() {
		if i == theIdx {
			return data.Destroy(entry)
		}
	}
	return
}
コード例 #3
0
ファイル: commands.go プロジェクト: DrGo/samay
func moveEntry(project, newProject *data.Project) error {
	for i, entry := range project.Entries() {
		if i == theIdx {
			entry.Project = newProject
			return data.Save(entry)
		}
	}
	return nil
}
コード例 #4
0
ファイル: status_test.go プロジェクト: DrGo/samay
func TestListProjects(t *testing.T) {
	var project *data.Project
	for _, project = range data.DB.Projects() {
		if ok, _ := project.OnClock(); ok {
			fmt.Printf("Project: %s (ticking...)\n",
				project.GetName(),
			)
		}
	}
}
コード例 #5
0
ファイル: commands.go プロジェクト: DrGo/samay
func moveProject(project, newProject *data.Project) error {
	for _, entry := range project.Entries() {
		entry.Project = newProject
		if err := data.Save(entry); err != nil {
			return err
		}
	}

	fmt.Printf("All entries copied to project \"%s\" \n...\n", newProject.GetName())
	return deleteProject(project)
}
コード例 #6
0
ファイル: commands.go プロジェクト: DrGo/samay
func deleteProject(project *data.Project) (err error) {
	var remove string
	fmt.Printf(
		"Remove all data for project \"%s\" ([No]/yes)? ",
		project.GetName(),
	)

	if fmt.Scanln(&remove); remove == "yes" {
		err = data.Destroy(project)
	}
	return
}
コード例 #7
0
ファイル: commands.go プロジェクト: DrGo/samay
func showProject(project *data.Project) (err error) {
	fmt.Printf("       id : %s\n", project.GetShaFromName())
	fmt.Printf("     name : %s\n", project.GetName())
	fmt.Printf("  entries : %d\n", len(project.Entries()))
	fmt.Printf(" location : %s\n", project.Location())
	return nil
}
コード例 #8
0
ファイル: commands.go プロジェクト: DrGo/samay
func showEntry(project *data.Project) (err error) {
	var started, ended *time.Time
	for i, entry := range project.Entries() {
		if i == theIdx {
			started, err = entry.StartedTime()
			ended, err = entry.EndedTime()
			fmt.Printf("       id : %s\n", entry.GetId())
			fmt.Printf(" contents : %s\n", entry.GetContent())
			fmt.Printf(" duration : %s\n", strings.Trim(entry.HoursMins().String(), " "))
			fmt.Printf("  started : %s\n", started)
			fmt.Printf("    ended : %s\n", ended)
			fmt.Printf("     tags : %v\n", entry.GetTags())
			fmt.Printf(" billable : %t\n", entry.GetBillable())
			break
		}
	}
	return err
}
コード例 #9
0
ファイル: commands.go プロジェクト: DrGo/samay
func stopTimer(project *data.Project) (err error) {
	return project.StopTimer(getContent(), billable)
}
コード例 #10
0
ファイル: commands.go プロジェクト: DrGo/samay
func startTimer(project *data.Project) (err error) {
	return project.StartTimer()
}