mirror of https://github.com/mvdan/fdroidcl.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
840 B
46 lines
840 B
|
11 years ago
|
// Copyright (c) 2015, Daniel Martí <mvdan@mvdan.cc>
|
||
|
|
// See LICENSE for licensing information
|
||
|
11 years ago
|
|
||
|
|
package main
|
||
|
|
|
||
|
11 years ago
|
import (
|
||
|
10 years ago
|
"errors"
|
||
|
11 years ago
|
"fmt"
|
||
|
|
)
|
||
|
11 years ago
|
|
||
|
|
var cmdUninstall = &Command{
|
||
|
|
UsageLine: "uninstall <appid...>",
|
||
|
|
Short: "Uninstall an app",
|
||
|
|
}
|
||
|
|
|
||
|
|
func init() {
|
||
|
|
cmdUninstall.Run = runUninstall
|
||
|
|
}
|
||
|
|
|
||
|
9 years ago
|
func runUninstall(args []string) error {
|
||
|
11 years ago
|
if len(args) < 1 {
|
||
|
9 years ago
|
return fmt.Errorf("no package names given")
|
||
|
|
}
|
||
|
|
device, err := oneDevice()
|
||
|
|
if err != nil {
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
inst, err := device.Installed()
|
||
|
|
if err != nil {
|
||
|
|
return err
|
||
|
11 years ago
|
}
|
||
|
|
for _, id := range args {
|
||
|
10 years ago
|
var err error
|
||
|
8 years ago
|
fmt.Fprintf(stdout, "Uninstalling %s\n", id)
|
||
|
10 years ago
|
if _, installed := inst[id]; installed {
|
||
|
|
err = device.Uninstall(id)
|
||
|
|
} else {
|
||
|
|
err = errors.New("not installed")
|
||
|
|
}
|
||
|
|
if err != nil {
|
||
|
9 years ago
|
return fmt.Errorf("could not uninstall %s: %v", id, err)
|
||
|
11 years ago
|
}
|
||
|
|
}
|
||
|
9 years ago
|
return nil
|
||
|
11 years ago
|
}
|