parent
5eed7949c1
commit
aa8e822c71
10
README.md
10
README.md
|
@ -94,6 +94,16 @@ $ dctlenv list-remote
|
||||||
0.2.3
|
0.2.3
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### `dctlenv uninstall [<version>]`
|
||||||
|
|
||||||
|
Uninstall a specific version of driftctl.
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ dctlenv uninstall 0.2.3
|
||||||
|
Uninstall driftctl v0.2.3
|
||||||
|
driftctl v0.2.3 is successfully uninstalled
|
||||||
|
```
|
||||||
|
|
||||||
### `dctlenv root`
|
### `dctlenv root`
|
||||||
|
|
||||||
Display the root directory where dctlenv is.
|
Display the root directory where dctlenv is.
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -uo pipefail
|
||||||
|
|
||||||
|
[ "$#" -gt 1 ] && log_error "Need 1 version instead of $#" 'usage: dctlenv uninstall [<version>]'
|
||||||
|
|
||||||
|
version_requested="${1:-""}"
|
||||||
|
[ -n "$version_requested" ] || log_error 'Version is not specified' 'usage: dctlenv uninstall [<version>]'
|
||||||
|
|
||||||
|
version="$(dctlenv-list 2>/dev/null | sed -E 's/^(\*| )? //g; s/ \(set by .+\)$//' | grep -e "$version_requested" | head -n 1)"
|
||||||
|
[ -n "$version" ] || log_error "No versions matching '$version_requested' found in local"
|
||||||
|
|
||||||
|
dst_path="$DCTLENV_ROOT/versions/$version"
|
||||||
|
if [ -f "$dst_path/driftctl" ]; then
|
||||||
|
echo "Uninstall driftctl v$version"
|
||||||
|
rm -r "$dst_path"
|
||||||
|
|
||||||
|
# If no versions remain, remove the versions directory
|
||||||
|
rmdir "$DCTLENV_ROOT/versions" 2>/dev/null
|
||||||
|
|
||||||
|
echo "driftctl v$version is successfully uninstalled"
|
||||||
|
fi
|
Loading…
Reference in New Issue