Exemplo n.º 1
0
func (store FolderStore) ListProjects(showarchive bool) (data.Projects, error) {
	db := store.db()
	keys, err := db.Keys()
	if err != nil {
		return data.Projects{}, errgo.Notef(err, "can not get keys from database")
	}

	out := data.NewProjects()
	for _, key := range keys {
		if !showarchive {
			// Skipping archived projects
			if len(key) > 0 {
				log.Debug("Key: ", key[0])

				if key[0] == ".archive" {
					continue
				}
			}
		}

		name := data.ProjectName(key)
		out.Add(data.Project{Name: name})
	}

	return out, nil
}
Exemplo n.º 2
0
// ProjectNamesFromArgs will return all projects or all projects with
// subprojects if the length of the args is not 0.
func ProjectNamesFromArgs(store store.Store, args []string, showarchive bool) (data.Projects, error) {
	projects, err := store.ListProjects(showarchive)
	if err != nil {
		return data.Projects{}, errgo.Notef(err, "can not get list of projects")
	}

	log.Debug("Args: ", args)

	out := data.NewProjects()
	if len(args) == 0 {
		out = projects
	} else {
		for _, arg := range args {
			name, err := data.ParseProjectName(arg)
			if err != nil {
				return data.Projects{}, errgo.Notef(err, "can not parse project name")
			}

			items := projects.List(data.Project{Name: name})
			for _, item := range items {
				out.Add(item)
			}
		}
	}

	return out, nil
}
Exemplo n.º 3
0
func GetTestProjects(notes, todos int, suffixes ...string) data.Projects {
	out := data.NewProjects()

	for _, suffix := range suffixes {
		out.Add(GetTestProject(suffix, notes, todos))
	}

	return out
}