You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
602 B
Go
28 lines
602 B
Go
2 years ago
|
package cli
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"os"
|
||
|
"path/filepath"
|
||
|
|
||
|
"github.com/urfave/cli/v2"
|
||
|
)
|
||
|
|
||
|
func uninstall(ctx *cli.Context) (err error) {
|
||
|
vname := ctx.Args().First()
|
||
|
if vname == "" {
|
||
|
return cli.ShowSubcommandHelp(ctx)
|
||
|
}
|
||
|
targetV := filepath.Join(versionsDir, vname)
|
||
|
|
||
|
if finfo, err := os.Stat(targetV); err != nil || !finfo.IsDir() {
|
||
|
return cli.Exit(fmt.Sprintf("[j] %q version is not installed", vname), 1)
|
||
|
}
|
||
|
|
||
|
if err = os.RemoveAll(targetV); err != nil {
|
||
|
return cli.Exit(wrapstring(fmt.Sprintf("Uninstall failed: %s", err.Error())), 1)
|
||
|
}
|
||
|
fmt.Printf("Uninstalled java %s\n", vname)
|
||
|
return nil
|
||
|
}
|