Beispiel #1
0
func handlePin(ctx *cli.Context, client *daemon.Client) error {
	path := ctx.Args().First()

	if ctx.Bool("is-pinned") {
		isPinned, err := client.IsPinned(path)
		if err != nil {
			return err
		}

		fmt.Printf("%s: %t\n", path, isPinned)
		return nil
	}

	fn := client.Pin
	if ctx.Bool("unpin") {
		fn = client.Unpin
	}

	if err := fn(path); err != nil {
		return err
	}

	return nil
}