Esempio n. 1
0
func activityCreate(c *cli.Context) error {
	ctx := context.Background()
	client, err := doaramacli.NewAuthenticatedDoaramaClient(c)
	if err != nil {
		return err
	}
	defer client.Close()
	activityType, err := doarama.DefaultActivityTypes.Find(doaramacli.ActivityType(c))
	if err != nil {
		return err
	}
	activityInfo := &doarama.ActivityInfo{
		TypeID: activityType.ID,
	}
	cache, err := newCache(c, client)
	if err != nil {
		return err
	}
	defer cache.Close()
	for _, arg := range c.Args() {
		a, err := activityCreateOne(ctx, cache, arg, activityInfo)
		if err != nil {
			log.Print(err)
			continue
		}
		fmt.Printf("ActivityId: %d\n", a.ID)
	}
	return nil
}
Esempio n. 2
0
func create(c *cli.Context) error {
	ctx := context.Background()
	client, err := doaramacli.NewAuthenticatedDoaramaClient(c)
	if err != nil {
		return err
	}
	defer client.Close()
	activityType, err := doarama.DefaultActivityTypes.Find(doaramacli.ActivityType(c))
	if err != nil {
		return err
	}
	activityInfo := &doarama.ActivityInfo{
		TypeID: activityType.ID,
	}
	cache, err := newCache(c, client)
	if err != nil {
		return err
	}
	defer cache.Close()
	var as []*doarama.Activity
	for _, arg := range c.Args() {
		var a *doarama.Activity
		a, err = activityCreateOne(ctx, cache, arg, activityInfo)
		if err != nil {
			break
		}
		fmt.Printf("ActivityId: %d\n", a.ID)
		as = append(as, a)
	}
	if err != nil {
		for _, a := range as {
			a.Delete(ctx)
		}
		return err
	}
	if len(as) == 0 {
		return errors.New("no activities specified")
	}
	v, err := client.CreateVisualisation(ctx, as)
	if err != nil {
		return err
	}
	fmt.Printf("VisualisationKey: %s\n", v.Key)
	vuo := doaramacli.NewVisualisationURLOptions(c)
	fmt.Printf("VisualisationURL: %s\n", v.URL(vuo))
	return nil
}