Skip to content

Commit 4cd3bd8

Browse files
authored
feat(install): Use Script Install (#163)
* feat(install): Use Script Install * change README
1 parent 7fcdbff commit 4cd3bd8

File tree

2 files changed

+112
-9
lines changed

2 files changed

+112
-9
lines changed

README.md

+25-9
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,36 @@ Also this tool can support output results **as a CSV file.**
2424
## Install
2525

2626
- Homebrew
27-
```sh
27+
28+
```bash
2829
brew install go-to-k/tap/lamver
2930
```
31+
32+
- Linux, Darwin (macOS) and Windows
33+
34+
```bash
35+
curl -fsSL https://raw.githubusercontent.com/go-to-k/lamver/main/install.sh | sh
36+
lamver -h
37+
38+
# To install a specific version of lamver
39+
# e.g. version 0.8.0
40+
curl -fsSL https://raw.githubusercontent.com/go-to-k/lamver/main/install.sh | sh -s "v0.8.0"
41+
lamver -h
42+
```
43+
3044
- Binary
3145
- [Releases](https://github.com/go-to-k/lamver/releases)
3246
- Git Clone and install(for developers)
33-
```sh
47+
48+
```bash
3449
git clone https://github.com/go-to-k/lamver.git
3550
cd lamver
3651
make install
3752
```
3853

3954
## How to use
40-
```sh
55+
56+
```bash
4157
lamver [-p <profile>] [-r <default region>] [-o <output file path>] [-k <keyword for function name>]
4258
```
4359
@@ -57,7 +73,7 @@ Also this tool can support output results **as a CSV file.**
5773
5874
### Enter `lamver`
5975
60-
```sh
76+
```bash
6177
❯ lamver
6278
```
6379
@@ -69,7 +85,7 @@ You can specify `-k, --keyword` option. This is a keyword for **function name fi
6985
7086
### Choose regions
7187
72-
```sh
88+
```bash
7389
? Select regions you want to search.
7490
[Use arrows to move, space to select, <right> to all, <left> to none, type to filter]
7591
[x] ap-northeast-1
@@ -93,7 +109,7 @@ You can specify `-k, --keyword` option. This is a keyword for **function name fi
93109
94110
### Choose runtime values
95111
96-
```sh
112+
```bash
97113
? Select runtime values you want to search.
98114
[Use arrows to move, space to select, <right> to all, <left> to none, type to filter]
99115
> [ ] dotnet6
@@ -142,13 +158,13 @@ You can search function names in a **case-insensitive**.
142158
143159
This phase is skipped if you specify `-k` option.
144160
145-
```sh
161+
```bash
146162
Filter a keyword of function names(case-insensitive): test-goto
147163
```
148164
149165
### The result will be output
150166
151-
```sh
167+
```bash
152168
+--------------+----------------+----------------------+------------------------------+
153169
| RUNTIME | REGION | FUNCTIONNAME | LASTMODIFIED |
154170
+--------------+----------------+----------------------+------------------------------+
@@ -181,6 +197,6 @@ By default, results are output as table format on the screen.
181197
182198
If you add `-o` option, then results can be output **as a CSV file**.
183199
184-
```sh
200+
```bash
185201
lamver -o ./result.csv
186202
```

install.sh

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/bin/bash
2+
3+
# This script automates the installation of the lamver tool.
4+
# It checks for the specified version (or fetches the latest one),
5+
# downloads the binary, and installs it on the system.
6+
7+
# Check for required tools: curl and tar.
8+
# These tools are necessary for downloading and extracting the lamver binary.
9+
if ! command -v curl &>/dev/null; then
10+
echo "curl could not be found"
11+
exit 1
12+
fi
13+
14+
if ! command -v tar &>/dev/null; then
15+
echo "tar could not be found"
16+
exit 1
17+
fi
18+
19+
# Determine the version of lamver to install.
20+
# If no version is specified as a command line argument, fetch the latest version.
21+
if [ -z "$1" ]; then
22+
VERSION=$(curl -s https://api.github.com/repos/go-to-k/lamver/releases/latest | grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/')
23+
if [ -z "$VERSION" ]; then
24+
echo "Failed to fetch the latest version"
25+
exit 1
26+
fi
27+
else
28+
VERSION=$1
29+
fi
30+
31+
# Normalize the version string by removing any leading 'v'.
32+
VERSION=${VERSION#v}
33+
34+
# Detect the architecture of the current system.
35+
# This script supports x86_64, arm64, and i386 architectures.
36+
ARCH=$(uname -m)
37+
case $ARCH in
38+
x86_64 | amd64) ARCH="x86_64" ;;
39+
arm64 | aarch64) ARCH="arm64" ;;
40+
i386 | i686) ARCH="i386" ;;
41+
*)
42+
echo "Unsupported architecture: $ARCH"
43+
exit 1
44+
;;
45+
esac
46+
47+
# Detect the operating system (OS) of the current system.
48+
# This script supports Linux, Darwin (macOS) and Windows operating systems.
49+
OS=$(uname -s)
50+
case $OS in
51+
Linux) OS="Linux" ;;
52+
Darwin) OS="Darwin" ;;
53+
MINGW* | MSYS* | CYGWIN*) OS="Windows" ;;
54+
*)
55+
echo "Unsupported OS: $OS"
56+
exit 1
57+
;;
58+
esac
59+
60+
# Construct the download URL for the lamver binary based on the version, OS, and architecture.
61+
FILE_NAME="lamver_${VERSION}_${OS}_${ARCH}.tar.gz"
62+
URL="https://github.com/go-to-k/lamver/releases/download/v${VERSION}/${FILE_NAME}"
63+
64+
# Download the lamver binary.
65+
echo "Downloading lamver..."
66+
if ! curl -L -o "$FILE_NAME" "$URL"; then
67+
echo "Failed to download lamver"
68+
exit 1
69+
fi
70+
71+
# Install lamver.
72+
# This involves extracting the binary and moving it to /usr/local/bin.
73+
echo "Installing lamver..."
74+
if ! tar -xzf "$FILE_NAME"; then
75+
echo "Failed to extract lamver"
76+
exit 1
77+
fi
78+
if ! sudo mv lamver /usr/local/bin/lamver; then
79+
echo "Failed to install lamver"
80+
exit 1
81+
fi
82+
83+
# Clean up by removing the downloaded tar file.
84+
rm "$FILE_NAME"
85+
86+
echo "lamver installation complete."
87+
echo "Run 'lamver -h' to see how to use lamver."

0 commit comments

Comments
 (0)