Skip to content

Commit

Permalink
Remove -s and add one-time alias
Browse files Browse the repository at this point in the history
  • Loading branch information
stevapple committed May 29, 2020
1 parent 2fe9567 commit 5ef5b56
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 37 deletions.
19 changes: 10 additions & 9 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ jobs:
chmod +x swiftbox.sh
./swiftbox.sh -v
./swiftbox.sh --version
./swiftbox.sh -v --short
./swiftbox.sh --version -s
- name: Test swiftbox help
run: |
Expand Down Expand Up @@ -147,8 +145,6 @@ jobs:
chmod +x swiftbox.sh
./swiftbox.sh -v
./swiftbox.sh --version
./swiftbox.sh -v --short
./swiftbox.sh --version -s
- name: Test swiftbox help
run: |
Expand All @@ -167,7 +163,15 @@ jobs:
shell: bash
run: swiftbox list

- name: Test swiftbox alias
- name: Test swiftbox short-term alias and check
env:
SWIFTBOX_SYSALIAS: 18.04
shell: bash
run: |
swiftbox check $MAINVER
swiftbox check nightly
- name: Test swiftbox long-term alias
run: |
swiftbox list
sudo sh -c 'echo "20.04" > /opt/swiftbox/.system-alias'
Expand Down Expand Up @@ -275,8 +279,7 @@ jobs:
chmod +x swiftbox.sh
./swiftbox.sh -v
./swiftbox.sh --version
./swiftbox.sh -v --short
./swiftbox.sh --version -s
- name: Test swiftbox help
run: |
Expand Down Expand Up @@ -394,8 +397,6 @@ jobs:
chmod +x swiftbox.sh
./swiftbox.sh -v
./swiftbox.sh --version
./swiftbox.sh -v --short
./swiftbox.sh --version -s
- name: Test swiftbox help
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/Tag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
name: Test swiftbox
run: |
chmod +x swiftbox.sh
VERSION=`./swiftbox.sh -v -s`
VERSION=`./swiftbox.sh -v`
echo "::set-env name=version::$VERSION"
if [ $? = 0 ]
then
Expand Down
25 changes: 15 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ You may notice a `[user]` or `[global]` prefix in the output, which indicates th

### Show `swiftbox` version

Both `swiftbox` amd system (or alias) version will be shown with `-v` or `--version`. Add `-s` or `--short` to omit system version.
`swiftbox` (and system alias) version will be shown with `-v` or `--version`.

```console
$ swiftbox --version
0.12.3 (Ubuntu 20.04)
$ swiftbox -v -s
0.12.3
$ swiftbox -v
0.12.3 (Ubuntu 20.04)
```

### Check the availability of Swift versions
Expand Down Expand Up @@ -122,14 +122,14 @@ $ sudo swiftbox close

### List local toolchain versions

The active one is marked with `*`. System versions will also be shown, and you can use `-s` or `--short` to omit.
The active one is marked with `*`. If the toolchain version does not match your system version, its platform version will also be shown.

```console
$ swiftbox list
- 2020-05-10-a (Ubuntu 20.04)
- 2020-05-10-a
- 4.2.1 (Ubuntu 18.04)
* 5.2.2 (Ubuntu 20.04)
$ sudo swiftbox list -s
* 5.2.2
$ sudo swiftbox list
- 2020-04-03-a
- 4.3
```
Expand Down Expand Up @@ -184,11 +184,9 @@ Commands:

### Alias your system version in `swiftbox`

Since Ubuntu has non-LTS versions and they may be (partially) compatible with toolchains built for LTS versions, `swiftbox` allows aliases (See #1) by specifying the version in `.system-alias` file in its working directory.
Since Ubuntu has non-LTS versions and they may be (partially) compatible with toolchains built for LTS versions, `swiftbox` allows long-term aliases (See #1) by specifying the version in `.system-alias` file in its working directory.

```console
$ swiftbox -v
0.12.3 (Ubuntu 19.10)
$ echo "20.04" > ~/.swiftbox/.system-alias
$ swiftbox -v
0.12.3 (Ubuntu 20.04)
Expand All @@ -197,6 +195,13 @@ Swift 5.2.4 is available for Ubuntu 20.04
You can get it with: swiftbox get 5.2.4
```

For one-time alias, use environmental variable `$SWIFTBOX_SYSALIAS` instead:

```console
$ export SWIFTBOX_SYSALIAS="20.04"
$ swiftbox get 5.2.4
```

## Known issues with upgrading

### Version < 0.11
Expand Down
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fi
if hash swiftbox 2> /dev/null
then
UPGRADE_COMMAND="upgrade"
SWIFTBOX_VERSION=`swiftbox -v -s`
SWIFTBOX_VERSION=`swiftbox -v`
if [ $? != 0 ]
then
UPGRADE_COMMAND="update"
Expand Down
32 changes: 16 additions & 16 deletions swiftbox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Set environment properties

SWIFTBOX_VERSION="0.12.3"
SWIFTBOX_VERSION="0.12.4"

if [ `id -u` = 0 ]
then
Expand All @@ -25,7 +25,10 @@ if [ -f /etc/os-release ]
then
source /etc/os-release
SYSTEM_NICENAME=$NAME
if [ -f $WORKING_DIR/.system-alias ]
if [ E$SWIFTBOX_SYSALIAS != E ]
then
SYSTEM_VERSION=$SWIFTBOX_SYSALIAS
elif [ -f $WORKING_DIR/.system-alias ]
then
SYSTEM_VERSION=`cat $WORKING_DIR/.system-alias`
else
Expand Down Expand Up @@ -302,7 +305,7 @@ install-toolchain() {
fi
tar -xzf download/$FILE_NAME.tar.gz -C temp
mv temp/$FILE_NAME toolchain/swift-$NEW_VERSION
echo $VERSION > $WORKING_DIR/toolchain/$file/.system-version
echo $SYSTEM_VERSION > $WORKING_DIR/toolchain/$file/.system-version
}

## Manage local toolchains
Expand Down Expand Up @@ -460,16 +463,15 @@ list)
then
if [ ! -f $WORKING_DIR/toolchain/$file/.system-version ]
then
echo $SYSTEM_VERSION > $WORKING_DIR/toolchain/$file/.system-version
echo $VERSION_ID > $WORKING_DIR/toolchain/$file/.system-version
fi
version=`cat $WORKING_DIR/toolchain/$file/.system-version`
case $2 in
-s | --short)
;;
*)
if [ $version = $VERSION_ID ]
then
SUFFIX=""
else
SUFFIX=" ($SYSTEM_NICENAME $version)"
;;
esac
fi
if [ $file = swift-`default-version` ]
then
echo "* ${file#swift\-}$SUFFIX"
Expand Down Expand Up @@ -525,14 +527,12 @@ upgrade)
exit $CURL_RESULT
;;
-v | --version)
case $2 in
-s | --short)
if [ $VERSION_ID = $SYSTEM_VERSION ]
then
echo $SWIFTBOX_VERSION
;;
*)
else
echo "$SWIFTBOX_VERSION ($SYSTEM_NICENAME $SYSTEM_VERSION)"
;;
esac
fi
;;
-h | --help)
cat <<EOF
Expand Down

0 comments on commit 5ef5b56

Please sign in to comment.