Skip to content

Commit 5ef5b56

Browse files
committed
Remove -s and add one-time alias
1 parent 2fe9567 commit 5ef5b56

File tree

5 files changed

+43
-37
lines changed

5 files changed

+43
-37
lines changed

.github/workflows/CI.yaml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ jobs:
2121
chmod +x swiftbox.sh
2222
./swiftbox.sh -v
2323
./swiftbox.sh --version
24-
./swiftbox.sh -v --short
25-
./swiftbox.sh --version -s
2624
2725
- name: Test swiftbox help
2826
run: |
@@ -147,8 +145,6 @@ jobs:
147145
chmod +x swiftbox.sh
148146
./swiftbox.sh -v
149147
./swiftbox.sh --version
150-
./swiftbox.sh -v --short
151-
./swiftbox.sh --version -s
152148
153149
- name: Test swiftbox help
154150
run: |
@@ -167,7 +163,15 @@ jobs:
167163
shell: bash
168164
run: swiftbox list
169165

170-
- name: Test swiftbox alias
166+
- name: Test swiftbox short-term alias and check
167+
env:
168+
SWIFTBOX_SYSALIAS: 18.04
169+
shell: bash
170+
run: |
171+
swiftbox check $MAINVER
172+
swiftbox check nightly
173+
174+
- name: Test swiftbox long-term alias
171175
run: |
172176
swiftbox list
173177
sudo sh -c 'echo "20.04" > /opt/swiftbox/.system-alias'
@@ -275,8 +279,7 @@ jobs:
275279
chmod +x swiftbox.sh
276280
./swiftbox.sh -v
277281
./swiftbox.sh --version
278-
./swiftbox.sh -v --short
279-
./swiftbox.sh --version -s
282+
280283
281284
- name: Test swiftbox help
282285
run: |
@@ -394,8 +397,6 @@ jobs:
394397
chmod +x swiftbox.sh
395398
./swiftbox.sh -v
396399
./swiftbox.sh --version
397-
./swiftbox.sh -v --short
398-
./swiftbox.sh --version -s
399400
400401
- name: Test swiftbox help
401402
run: |

.github/workflows/Tag.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
name: Test swiftbox
1616
run: |
1717
chmod +x swiftbox.sh
18-
VERSION=`./swiftbox.sh -v -s`
18+
VERSION=`./swiftbox.sh -v`
1919
echo "::set-env name=version::$VERSION"
2020
if [ $? = 0 ]
2121
then

README.md

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ You may notice a `[user]` or `[global]` prefix in the output, which indicates th
7272

7373
### Show `swiftbox` version
7474

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

7777
```console
7878
$ swiftbox --version
79-
0.12.3 (Ubuntu 20.04)
80-
$ swiftbox -v -s
8179
0.12.3
80+
$ swiftbox -v
81+
0.12.3 (Ubuntu 20.04)
8282
```
8383

8484
### Check the availability of Swift versions
@@ -122,14 +122,14 @@ $ sudo swiftbox close
122122

123123
### List local toolchain versions
124124

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

127127
```console
128128
$ swiftbox list
129-
- 2020-05-10-a (Ubuntu 20.04)
129+
- 2020-05-10-a
130130
- 4.2.1 (Ubuntu 18.04)
131-
* 5.2.2 (Ubuntu 20.04)
132-
$ sudo swiftbox list -s
131+
* 5.2.2
132+
$ sudo swiftbox list
133133
- 2020-04-03-a
134134
- 4.3
135135
```
@@ -184,11 +184,9 @@ Commands:
184184

185185
### Alias your system version in `swiftbox`
186186

187-
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.
187+
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.
188188

189189
```console
190-
$ swiftbox -v
191-
0.12.3 (Ubuntu 19.10)
192190
$ echo "20.04" > ~/.swiftbox/.system-alias
193191
$ swiftbox -v
194192
0.12.3 (Ubuntu 20.04)
@@ -197,6 +195,13 @@ Swift 5.2.4 is available for Ubuntu 20.04
197195
You can get it with: swiftbox get 5.2.4
198196
```
199197

198+
For one-time alias, use environmental variable `$SWIFTBOX_SYSALIAS` instead:
199+
200+
```console
201+
$ export SWIFTBOX_SYSALIAS="20.04"
202+
$ swiftbox get 5.2.4
203+
```
204+
200205
## Known issues with upgrading
201206

202207
### Version < 0.11

install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ fi
5252
if hash swiftbox 2> /dev/null
5353
then
5454
UPGRADE_COMMAND="upgrade"
55-
SWIFTBOX_VERSION=`swiftbox -v -s`
55+
SWIFTBOX_VERSION=`swiftbox -v`
5656
if [ $? != 0 ]
5757
then
5858
UPGRADE_COMMAND="update"

swiftbox.sh

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Set environment properties
44

5-
SWIFTBOX_VERSION="0.12.3"
5+
SWIFTBOX_VERSION="0.12.4"
66

77
if [ `id -u` = 0 ]
88
then
@@ -25,7 +25,10 @@ if [ -f /etc/os-release ]
2525
then
2626
source /etc/os-release
2727
SYSTEM_NICENAME=$NAME
28-
if [ -f $WORKING_DIR/.system-alias ]
28+
if [ E$SWIFTBOX_SYSALIAS != E ]
29+
then
30+
SYSTEM_VERSION=$SWIFTBOX_SYSALIAS
31+
elif [ -f $WORKING_DIR/.system-alias ]
2932
then
3033
SYSTEM_VERSION=`cat $WORKING_DIR/.system-alias`
3134
else
@@ -302,7 +305,7 @@ install-toolchain() {
302305
fi
303306
tar -xzf download/$FILE_NAME.tar.gz -C temp
304307
mv temp/$FILE_NAME toolchain/swift-$NEW_VERSION
305-
echo $VERSION > $WORKING_DIR/toolchain/$file/.system-version
308+
echo $SYSTEM_VERSION > $WORKING_DIR/toolchain/$file/.system-version
306309
}
307310

308311
## Manage local toolchains
@@ -460,16 +463,15 @@ list)
460463
then
461464
if [ ! -f $WORKING_DIR/toolchain/$file/.system-version ]
462465
then
463-
echo $SYSTEM_VERSION > $WORKING_DIR/toolchain/$file/.system-version
466+
echo $VERSION_ID > $WORKING_DIR/toolchain/$file/.system-version
464467
fi
465468
version=`cat $WORKING_DIR/toolchain/$file/.system-version`
466-
case $2 in
467-
-s | --short)
468-
;;
469-
*)
469+
if [ $version = $VERSION_ID ]
470+
then
471+
SUFFIX=""
472+
else
470473
SUFFIX=" ($SYSTEM_NICENAME $version)"
471-
;;
472-
esac
474+
fi
473475
if [ $file = swift-`default-version` ]
474476
then
475477
echo "* ${file#swift\-}$SUFFIX"
@@ -525,14 +527,12 @@ upgrade)
525527
exit $CURL_RESULT
526528
;;
527529
-v | --version)
528-
case $2 in
529-
-s | --short)
530+
if [ $VERSION_ID = $SYSTEM_VERSION ]
531+
then
530532
echo $SWIFTBOX_VERSION
531-
;;
532-
*)
533+
else
533534
echo "$SWIFTBOX_VERSION ($SYSTEM_NICENAME $SYSTEM_VERSION)"
534-
;;
535-
esac
535+
fi
536536
;;
537537
-h | --help)
538538
cat <<EOF

0 commit comments

Comments
 (0)